text
stringlengths
4
1.01M
<?php /* Class to send push notifications using Google Cloud Messaging for Android Example usage ----------------------- $an = new GCMPushMessage($apiKey); $an->setDevices($devices); $response = $an->send($message); ----------------------- $apiKey Your GCM api key $devices An array or string of registered device tokens $message The mesasge you want to push out @author Matt Grundy Adapted from the code available at: http://stackoverflow.com/questions/11242743/gcm-with-php-google-cloud-messaging */ class GCMPushMessage { // the URL of the GCM API endpoint private $url = 'https://android.googleapis.com/gcm/send'; // the server API key - setup on class init private $serverApiKey = ""; // array of devices to send to private $devices = array(); /* Constructor @param $apiKeyIn the server API key */ function GCMPushMessage($apiKeyIn){ $this->serverApiKey = $apiKeyIn; } /* Set the devices to send to @param $deviceIds array of device tokens to send to */ function setDevices($deviceIds){ if(is_array($deviceIds)){ $this->devices = $deviceIds; } else { $this->devices = array($deviceIds); } } /* Send the message to the device @param $message The message to send @param $data Array of data to accompany the message */ function send($message, $data = false){ if(!is_array($this->devices) || count($this->devices) == 0){ throw new GCMPushMessageArgumentException("No devices set"); } if(strlen($this->serverApiKey) < 8){ throw new GCMPushMessageArgumentException("Server API Key not set"); } $fields = array( 'registration_ids' => $this->devices, 'data' => array( "message" => $message ), ); if(is_array($data)){ foreach ($data as $key => $value) { $fields['data'][$key] = $value; } } $headers = array( 'Authorization: key=' . $this->serverApiKey, 'Content-Type: application/json' ); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt( $ch, CURLOPT_URL, $this->url ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) ); // Avoids problem with https certificate curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); // Execute post $result = curl_exec($ch); // Close connection curl_close($ch); return $result; } } class GCMPushMessageArgumentException extends Exception { public function __construct($message, $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } public function __toString() { return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; } }
export * from './code-editor-grid.component';
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef __TESTS_SCRIPT_HPP__ #define __TESTS_SCRIPT_HPP__ #include <gtest/gtest.h> namespace mesos { namespace internal { namespace tests { // Helper used by TEST_SCRIPT to execute the script. void execute(const std::string& script); } // namespace tests { } // namespace internal { } // namespace mesos { // Runs the given script (relative to src/tests). We execute this // script in temporary directory and pipe its output to '/dev/null' // unless the verbose option is specified. The "test" passes if the // script returns 0. #define TEST_SCRIPT(test_case_name, test_name, script) \ TEST(test_case_name, test_name) { \ mesos::internal::tests::execute(script); \ } #endif // __TESTS_SCRIPT_HPP__
var tests = []; for (var file in window.__karma__.files) { if (/Spec\.js$/.test(file)) { tests.push(file); } } requirejs.config({ // Karma serves files from '/base' baseUrl: '.', paths: { }, shim: { 'underscore': { exports: '_' } }, // ask Require.js to load these files (all our tests) deps: tests, // start test run, once Require.js is done callback: window.__karma__.start });
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is also distributed with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have included with MySQL. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file storage/perfschema/table_esms_global_by_event_name.cc Table EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_EVENT_NAME (implementation). */ #include "my_global.h" #include "my_thread.h" #include "pfs_instr_class.h" #include "pfs_column_types.h" #include "pfs_column_values.h" #include "table_esms_global_by_event_name.h" #include "pfs_global.h" #include "pfs_instr.h" #include "pfs_timer.h" #include "pfs_visitor.h" #include "field.h" THR_LOCK table_esms_global_by_event_name::m_table_lock; static const TABLE_FIELD_TYPE field_types[]= { { { C_STRING_WITH_LEN("EVENT_NAME") }, { C_STRING_WITH_LEN("varchar(128)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("COUNT_STAR") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_LOCK_TIME") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_ERRORS") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_WARNINGS") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_ROWS_SENT") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SELECT_RANGE") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SELECT_SCAN") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SORT_RANGE") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SORT_ROWS") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_SORT_SCAN") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} }, { { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") }, { C_STRING_WITH_LEN("bigint(20)") }, { NULL, 0} } }; TABLE_FIELD_DEF table_esms_global_by_event_name::m_field_def= { 25, field_types }; PFS_engine_table_share table_esms_global_by_event_name::m_share= { { C_STRING_WITH_LEN("events_statements_summary_global_by_event_name") }, &pfs_truncatable_acl, table_esms_global_by_event_name::create, NULL, /* write_row */ table_esms_global_by_event_name::delete_all_rows, table_esms_global_by_event_name::get_row_count, sizeof(PFS_simple_index), &m_table_lock, &m_field_def, false, /* checked */ false /* perpetual */ }; PFS_engine_table* table_esms_global_by_event_name::create(void) { return new table_esms_global_by_event_name(); } int table_esms_global_by_event_name::delete_all_rows(void) { reset_events_statements_by_thread(); reset_events_statements_by_account(); reset_events_statements_by_user(); reset_events_statements_by_host(); reset_events_statements_global(); return 0; } ha_rows table_esms_global_by_event_name::get_row_count(void) { return statement_class_max; } table_esms_global_by_event_name::table_esms_global_by_event_name() : PFS_engine_table(&m_share, &m_pos), m_row_exists(false), m_pos(1), m_next_pos(1) {} void table_esms_global_by_event_name::reset_position(void) { m_pos= 1; m_next_pos= 1; } int table_esms_global_by_event_name::rnd_init(bool scan) { m_normalizer= time_normalizer::get(statement_timer); return 0; } int table_esms_global_by_event_name::rnd_next(void) { PFS_statement_class *statement_class; if (global_instr_class_statements_array == NULL) return HA_ERR_END_OF_FILE; m_pos.set_at(&m_next_pos); statement_class= find_statement_class(m_pos.m_index); if (statement_class) { make_row(statement_class); m_next_pos.set_after(&m_pos); return 0; } return HA_ERR_END_OF_FILE; } int table_esms_global_by_event_name::rnd_pos(const void *pos) { PFS_statement_class *statement_class; set_position(pos); if (global_instr_class_statements_array == NULL) return HA_ERR_END_OF_FILE; statement_class=find_statement_class(m_pos.m_index); if (statement_class) { make_row(statement_class); return 0; } return HA_ERR_RECORD_DELETED; } void table_esms_global_by_event_name ::make_row(PFS_statement_class *klass) { m_row_exists= false; if (klass->is_mutable()) return; m_row.m_event_name.make_row(klass); PFS_connection_statement_visitor visitor(klass); PFS_connection_iterator::visit_global(true, /* hosts */ false, /* users */ true, /* accounts */ true, /* threads */ false, /* THDs */ & visitor); m_row.m_stat.set(m_normalizer, & visitor.m_stat); m_row_exists= true; } int table_esms_global_by_event_name ::read_row_values(TABLE *table, unsigned char *, Field **fields, bool read_all) { Field *f; if (unlikely(! m_row_exists)) return HA_ERR_RECORD_DELETED; /* Set the null bits */ DBUG_ASSERT(table->s->null_bytes == 0); for (; (f= *fields) ; fields++) { if (read_all || bitmap_is_set(table->read_set, f->field_index)) { switch(f->field_index) { case 0: /* NAME */ m_row.m_event_name.set_field(f); break; default: /* 1, ... COUNT/SUM/MIN/AVG/MAX */ m_row.m_stat.set_field(f->field_index - 1, f); break; } } } return 0; }
# Angular 4 + spin.js Not long ago I was working on a project using Angular 4 and as with many applications I needed a loading indicator. After doing a bit of searching I decided to use Spin.js, a really cool JavaScript library that can be used to render a 'spinner' without using external images/css. I then started thinking, how do I do this with Angular 4... do I need a component that I put in every page, is there a way to share a single root level component with my app, etc. I then came across a really good blog by Tom Buyse explaining how to setup an observable subscription in order to control a single component using a service that you pass around your application (Thanks Tom!). I think this can be a really useful pattern of development for a number of purposes, but here's a look at how I created an Angular2 spinner component with Spin.js. (Note: I eventually found better aesthetics using @angular/material's progress indicator and abandoned this, but it was still a good learning effort) ### The spinner component First of all I created the component that I'll put an instance of in my root application view. ``` @Component({ selector: 'sjs-spinner', templateUrl: './spinner.component.html' }) export class SpinnerComponent implements OnInit, OnDestroy { . ``` In the component I exposed the Spin.js options as Angular2 component inputs ``` @Input() lines: number = 12; // The number of lines to draw @Input() length: number = 20; // The length of each line @Input() width: number = 12; // The line thickness @Input() radius: number = 50; // The radius of the inner circle @Input() scale: number = 1.0; // Scales overall size of the spinner . . . ``` Then on the component's ngOnInit callback I initialize the component with a setup of inputs from the view specifying spin.js options. It's important to do so in the ngOnInit callback as in the constructor would be too early and the inputs are not passed from the parent view element. ``` ngOnInit() { this.initSpinner(); this.createServiceSubscription(); } private initSpinner() { let options = { lines: this.lines, length: this.length, width: this.width, radius: this.radius, scale: this.scale, corners: this.corners, color: this.color, opacity: this.opacity, rotate: this.rotate, direction: this.direction, speed: this.speed, trail: this.trail, fps: this.fps, zIndex: 2e9, // Artificially high z-index to keep on top className: this.className, top: this.top, left: this.left, shadow: this.shadow, hwaccel: this.hwaccel, position: this.position }; console.log('Creating spinner with options:'); console.log(JSON.stringify((options))); this.spinner = new Spinner(options); } ``` Now we've got an instance of the spin.js object created than we can show and hide as needed. Next comes the magic, we create a service that holds a shared observable in order to control the spinner component from other components within the application. Note: it's important to import the Rxjs 'share' operator in order to create the shared observable, I did so in a file called rxjs-operators.ts that I've imported into my main application component. ``` @Injectable() export class SpinnerService { private spinnerObserver: Observer<boolean>; public spinnerObservable: Observable<boolean>; constructor() { this.spinnerObservable = new Observable<boolean>(observer => { this.spinnerObserver = observer; } ).share(); } } ``` The spinner component can then subscribe to this observable and receive notifications from the service as whether it should show or hide the spinner. I've also called this subscription code from within the ngOnInit callback, though it'd be fine to do so within the component constructor as well. ``` private createServiceSubscription() { this.subscription = this.spinnerService.spinnerObservable.subscribe(show => { if (show) { this.startSpinner(); } else { this.stopSpinner(); } }); } ``` The service can use the observable in order to trigger the show and hide states in the component. ``` show() { if (this.spinnerObserver) { this.spinnerObserver.next(true); } } hide() { if (this.spinnerObserver) { this.spinnerObserver.next(false); } } ``` Now I can drop an instance of my spinner component in my main app component specifying it's view options: ``` <ng2-spinner [radius]="25" [lines]="15" [width]="8" [length]="15" [opacity]="0.1" [shadow]="true"></ng2-spinner> ``` And pass around the spinner service to control showing/hiding it everywhere else in my application ``` constructor(private spinnerService: SpinnerService) { } public spin(event: MouseEvent): void { event.preventDefault(); this.spinnerService.show(); setTimeout(() => { this.spinnerService.hide(); }, 1000); } ``` I think this is a really useful pattern and can imagine it'll come in handy on my current and future projects. So far I really like Angular2, I think it brings some sanity back to client side web application development. I can only imagine I'll get more than 1 grumble about that comment, but so far I've found it to be a great development experience. http://tombuyse.com/creating-a-loading-indicator-in-angular-2-ionic-2/ http://spin.js.org/
module AdminAnnotationsHelper end
{default_translation_domain domain='comment.fo.default'} {$locale={lang attr="locale"}} {$customer_id={customer attr="id"}} {ifloop rel="comments"} {function name=comment_stars empty=1} {$star='<span class="glyphicon glyphicon-star"></span>'} {$star_empty='<span class="glyphicon glyphicon-star-empty"></span>'} {for $foo=0 to 4} {if $value > $foo} {$star nofilter} {elseif $empty == 1} {$star_empty nofilter} {/if} {/for} {/function} {loop name="comments" type="comment" ref="{$ref}" ref_id="{$ref_id}" status="1" order="created_reverse" offset="{$start}" limit="{$count}" } {if $CUSTOMER_ID} {loop name="customer" type="customer" id="{$CUSTOMER_ID}" current="false" limit="1"} {$username="{$FIRSTNAME} {$LASTNAME|truncate:2:"...":false}"} {$image="http://www.gravatar.com/avatar/{$EMAIL|trim|strtolower|md5}?d=mm&s=64"} {/loop} {elseloop rel="customer"} {$username={intl l="Anonymous"} } {$image={image file='assets/img/avatar.png'}} {/elseloop} {else} {$username=$USERNAME} {$image="http://www.gravatar.com/avatar/{$EMAIL|trim|strtolower|md5}?d=mm&s=64"} {/if} <div id="comment-customer" class="comment-item media"> <img src="{$image}" alt="" class="pull-left" /> <div class="media-body"> <p> {intl l="By <strong>%username</strong>" username={$username}} {if $RATING}<span class="text-primary">{comment_stars value=$RATING}</span>{/if} </p> <h3 class="comment-title media-heading">{$TITLE}</h3> <p class="comment-message">{$CONTENT}</p> <div class="comment-alert alert hidden"></div> <ul class="comment-extra list-inline"> <li class="comment-date">{format_date date="{$CREATED}" output="date"}</li> {if $VERIFIED} <li class="comment-verified comment--is-verified">{intl l="Verified"}</li> {else} <li class="comment-verified">{intl l="Verified"}</li> {/if} {if $customer_id && $customer_id == $CUSTOMER_ID} <li><a href="{url path="/comment/delete/{$ID}"}" class="delete-trigger" data-id="{$ID}" data-message="{intl l="Are you sure ?"}">{intl l="Delete"}</a></li> {else} <li class="comment-abuse"> {form name="comment.abuse.form"} <form id="form-add-comment" action="{url path="/comment/abuse"}" method="post" novalidate> {form_hidden_fields form=$form} {form_field form=$form field="id"} <input type="hidden" name="{$name}" value="{$ID}" /> <a href="#" class="abuse-trigger">{intl l="Mark as inappropriate"}</a> {/form_field} </form> {/form} </li> {/if} </ul> </div> </div> {/loop} {if {count type="comment" ref="{$ref}" ref_id="{$ref_id}" status="1" } > $start + $count } <div class="comments-more"> <a href="#" class="comments-more-link">{intl l="Load more comments..."}</a> </div> {/if} {/ifloop} {elseloop rel="comments"} <div class="alert alert-info"> {if $start == 0 } {intl l="There are no comments yet"} {else} {intl l="No more comments"} {/if} </div> {/elseloop}
/*************************************************************************** * Copyright (C) 2007 by Benedikt Sauter * * sauter@ixbat.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ /* * This file is based on Dominic Rath's amt_jtagaccel.c. * * usbprog is a free programming adapter. You can easily install * different firmware versions from an "online pool" over USB. * The adapter can be used for programming and debugging AVR and ARM * processors, as USB to RS232 converter, as JTAG interface or as * simple I/O interface (5 lines). * * http://www.embedded-projects.net/usbprog */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <jtag/interface.h> #include <jtag/commands.h> #include "usb_common.h" #define VID 0x1781 #define PID 0x0c63 /* Pins at usbprog */ #define TDO_BIT 0 #define TDI_BIT 3 #define TCK_BIT 2 #define TMS_BIT 1 static void usbprog_end_state(tap_state_t state); static void usbprog_state_move(void); static void usbprog_path_move(struct pathmove_command *cmd); static void usbprog_runtest(int num_cycles); static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size); #define UNKOWN_COMMAND 0x00 #define PORT_DIRECTION 0x01 #define PORT_SET 0x02 #define PORT_GET 0x03 #define PORT_SETBIT 0x04 #define PORT_GETBIT 0x05 #define WRITE_TDI 0x06 #define READ_TDO 0x07 #define WRITE_AND_READ 0x08 #define WRITE_TMS 0x09 #define WRITE_TMS_CHAIN 0x0A struct usbprog_jtag { struct usb_dev_handle* usb_handle; }; static struct usbprog_jtag * usbprog_jtag_handle; static struct usbprog_jtag* usbprog_jtag_open(void); //static void usbprog_jtag_close(struct usbprog_jtag *usbprog_jtag); static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag); static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen); static void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char * buffer, int size); static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char * buffer, int size); static void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char * buffer, int size); static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan); static char tms_chain[64]; static int tms_chain_index; static void usbprog_jtag_tms_collect(char tms_scan); static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag); static void usbprog_write(int tck, int tms, int tdi); static void usbprog_reset(int trst, int srst); static void usbprog_jtag_set_direction(struct usbprog_jtag *usbprog_jtag, unsigned char direction); static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag,unsigned char value); //static unsigned char usbprog_jtag_get_port(struct usbprog_jtag *usbprog_jtag); static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag,int bit, int value); //static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit); static int usbprog_speed(int speed) { return ERROR_OK; } static int usbprog_execute_queue(void) { struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; while (cmd) { switch (cmd->type) { case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); #endif if (cmd->cmd.reset->trst == 1) { tap_set_state(TAP_RESET); } usbprog_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); break; case JTAG_RUNTEST: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, cmd->cmd.runtest->end_state); #endif usbprog_end_state(cmd->cmd.runtest->end_state); usbprog_runtest(cmd->cmd.runtest->num_cycles); break; case JTAG_TLR_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state); #endif usbprog_end_state(cmd->cmd.statemove->end_state); usbprog_state_move(); break; case JTAG_PATHMOVE: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); #endif usbprog_path_move(cmd->cmd.pathmove); break; case JTAG_SCAN: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("scan end in %i", cmd->cmd.scan->end_state); #endif usbprog_end_state(cmd->cmd.scan->end_state); scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); type = jtag_scan_type(cmd->cmd.scan); usbprog_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) return ERROR_JTAG_QUEUE_FAILED; if (buffer) free(buffer); break; case JTAG_SLEEP: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("sleep %i", cmd->cmd.sleep->us); #endif jtag_sleep(cmd->cmd.sleep->us); break; default: LOG_ERROR("BUG: unknown JTAG command type encountered"); exit(-1); } cmd = cmd->next; } return ERROR_OK; } static int usbprog_init(void) { usbprog_jtag_handle = usbprog_jtag_open(); tms_chain_index = 0; if (usbprog_jtag_handle == 0) { LOG_ERROR("Can't find USB JTAG Interface! Please check connection and permissions."); return ERROR_JTAG_INIT_FAILED; } LOG_INFO("USB JTAG Interface ready!"); usbprog_jtag_init(usbprog_jtag_handle); usbprog_reset(0, 0); usbprog_write(0, 0, 0); return ERROR_OK; } static int usbprog_quit(void) { return ERROR_OK; } /*************** jtag execute commands **********************/ static void usbprog_end_state(tap_state_t state) { if (tap_is_state_stable(state)) tap_set_end_state(state); else { LOG_ERROR("BUG: %i is not a valid end state", state); exit(-1); } } static void usbprog_state_move(void) { int i = 0, tms = 0; uint8_t tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state()); usbprog_jtag_write_tms(usbprog_jtag_handle, (char)tms_scan); for (i = 0; i < tms_count; i++) { tms = (tms_scan >> i) & 1; } tap_set_state(tap_get_end_state()); } static void usbprog_path_move(struct pathmove_command *cmd) { int num_states = cmd->num_states; int state_count; /* There may be queued transitions, and before following a specified path, we must flush those queued transitions */ usbprog_jtag_tms_send(usbprog_jtag_handle); state_count = 0; while (num_states) { if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count]) { /* LOG_INFO("1"); */ usbprog_write(0, 0, 0); usbprog_write(1, 0, 0); } else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count]) { /* LOG_INFO("2"); */ usbprog_write(0, 1, 0); usbprog_write(1, 1, 0); } else { LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(cmd->path[state_count])); exit(-1); } tap_set_state(cmd->path[state_count]); state_count++; num_states--; } tap_set_end_state(tap_get_state()); } static void usbprog_runtest(int num_cycles) { int i; /* only do a state_move when we're not already in IDLE */ if (tap_get_state() != TAP_IDLE) { usbprog_end_state(TAP_IDLE); usbprog_state_move(); } /* execute num_cycles */ if (num_cycles > 0) { usbprog_jtag_tms_send(usbprog_jtag_handle); usbprog_write(0, 0, 0); } else { usbprog_jtag_tms_send(usbprog_jtag_handle); /* LOG_INFO("NUM CYCLES %i",num_cycles); */ } for (i = 0; i < num_cycles; i++) { usbprog_write(1, 0, 0); usbprog_write(0, 0, 0); } #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("runtest: cur_state %s end_state %s", tap_state_name(tap_get_state()), tap_state_name(tap_get_end_state())); #endif /* finish in end_state */ /* usbprog_end_state(saved_end_state); if (tap_get_state() != tap_get_end_state()) usbprog_state_move(); */ } static void usbprog_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, int scan_size) { tap_state_t saved_end_state = tap_get_end_state(); if (ir_scan) usbprog_end_state(TAP_IRSHIFT); else usbprog_end_state(TAP_DRSHIFT); /* Only move if we're not already there */ if (tap_get_state() != tap_get_end_state()) usbprog_state_move(); usbprog_end_state(saved_end_state); usbprog_jtag_tms_send(usbprog_jtag_handle); void (*f)(struct usbprog_jtag *usbprog_jtag, char * buffer, int size); switch (type) { case SCAN_OUT: f = &usbprog_jtag_write_tdi; break; case SCAN_IN: f = &usbprog_jtag_read_tdo; break; case SCAN_IO: f = &usbprog_jtag_write_and_read; break; default: LOG_ERROR("unknown scan type: %i", type); exit(-1); } f(usbprog_jtag_handle, (char *)buffer, scan_size); /* The adapter does the transition to PAUSE internally */ if (ir_scan) tap_set_state(TAP_IRPAUSE); else tap_set_state(TAP_DRPAUSE); if (tap_get_state() != tap_get_end_state()) usbprog_state_move(); } /*************** jtag wrapper functions *********************/ static void usbprog_write(int tck, int tms, int tdi) { unsigned char output_value = 0x00; if (tms) output_value |= (1 << TMS_BIT); if (tdi) output_value |= (1 << TDI_BIT); if (tck) output_value |= (1 << TCK_BIT); usbprog_jtag_write_slice(usbprog_jtag_handle,output_value); } /* (1) assert or (0) deassert reset lines */ static void usbprog_reset(int trst, int srst) { LOG_DEBUG("trst: %i, srst: %i", trst, srst); if (trst) usbprog_jtag_set_bit(usbprog_jtag_handle, 5, 0); else usbprog_jtag_set_bit(usbprog_jtag_handle, 5, 1); if (srst) usbprog_jtag_set_bit(usbprog_jtag_handle, 4, 0); else usbprog_jtag_set_bit(usbprog_jtag_handle, 4, 1); } /*************** jtag lowlevel functions ********************/ struct usb_bus *busses; struct usbprog_jtag* usbprog_jtag_open(void) { usb_set_debug(10); usb_init(); const uint16_t vids[] = { VID, 0 }; const uint16_t pids[] = { PID, 0 }; struct usb_dev_handle *dev; if (jtag_usb_open(vids, pids, &dev) != ERROR_OK) return NULL; struct usbprog_jtag *tmp = malloc(sizeof(struct usbprog_jtag)); tmp->usb_handle = dev; usb_set_configuration(dev, 1); usb_claim_interface(dev, 0); usb_set_altinterface(dev, 0); return tmp; } #if 0 static void usbprog_jtag_close(struct usbprog_jtag *usbprog_jtag) { usb_close(usbprog_jtag->usb_handle); free(usbprog_jtag); } #endif static unsigned char usbprog_jtag_message(struct usbprog_jtag *usbprog_jtag, char *msg, int msglen) { int res = usb_bulk_write(usbprog_jtag->usb_handle, 3, msg,msglen, 100); if ((msg[0] == 2) || (msg[0] == 1) || (msg[0] == 4) || (msg[0] == 0) || \ (msg[0] == 6) || (msg[0] == 0x0A) || (msg[0] == 9)) return 1; if (res == msglen) { /* LOG_INFO("HALLLLOOO %i",(int)msg[0]); */ res = usb_bulk_read(usbprog_jtag->usb_handle, 0x82, msg, 2, 100); if (res > 0) return (unsigned char)msg[1]; else return -1; } else return -1; return 0; } static void usbprog_jtag_init(struct usbprog_jtag *usbprog_jtag) { usbprog_jtag_set_direction(usbprog_jtag, 0xFE); } static void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char * buffer, int size) { char tmp[64]; /* fastes packet size for usb controller */ int send_bits, bufindex = 0, fillindex = 0, i, loops; char swap; /* 61 byte can be transfered (488 bit) */ while (size > 0) { if (size > 488) { send_bits = 488; size = size - 488; loops = 61; } else { send_bits = size; loops = size / 8; loops++; size = 0; } tmp[0] = WRITE_AND_READ; tmp[1] = (char)(send_bits >> 8); /* high */ tmp[2] = (char)(send_bits); /* low */ i = 0; for (i = 0; i < loops; i++) { tmp[3 + i] = buffer[bufindex]; bufindex++; } if (usb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 64, 1000) == 64) { /* LOG_INFO("HALLLLOOO2 %i",(int)tmp[0]); */ usleep(1); int timeout = 0; while (usb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 1000) < 1) { timeout++; if (timeout > 10) break; } for (i = 0; i < loops; i++) { swap = tmp[3 + i]; buffer[fillindex++] = swap; } } } } static void usbprog_jtag_read_tdo(struct usbprog_jtag *usbprog_jtag, char * buffer, int size) { char tmp[64]; /* fastes packet size for usb controller */ int send_bits, fillindex = 0, i, loops; char swap; /* 61 byte can be transfered (488 bit) */ while (size > 0) { if (size > 488) { send_bits = 488; size = size - 488; loops = 61; } else { send_bits = size; loops = size / 8; loops++; size = 0; } tmp[0] = WRITE_AND_READ; tmp[1] = (char)(send_bits >> 8); /* high */ tmp[2] = (char)(send_bits); /* low */ usb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 3, 1000); /* LOG_INFO("HALLLLOOO3 %i",(int)tmp[0]); */ int timeout = 0; usleep(1); while (usb_bulk_read(usbprog_jtag->usb_handle, 0x82, tmp, 64, 10) < 1) { timeout++; if (timeout > 10) break; } for (i = 0; i < loops; i++) { swap = tmp[3 + i]; buffer[fillindex++] = swap; } } } static void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char * buffer, int size) { char tmp[64]; /* fastes packet size for usb controller */ int send_bits, bufindex = 0, i, loops; /* 61 byte can be transfered (488 bit) */ while (size > 0) { if (size > 488) { send_bits = 488; size = size - 488; loops = 61; } else { send_bits = size; loops = size/8; /* if (loops == 0) */ loops++; size = 0; } tmp[0] = WRITE_TDI; tmp[1] = (char)(send_bits >> 8); /* high */ tmp[2] = (char)(send_bits); /* low */ i = 0; for (i = 0; i < loops; i++) { tmp[3 + i] = buffer[bufindex]; bufindex++; } usb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, 64, 1000); } } static void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan) { usbprog_jtag_tms_collect(tms_scan); } static void usbprog_jtag_set_direction(struct usbprog_jtag *usbprog_jtag, unsigned char direction) { char tmp[2]; tmp[0] = PORT_DIRECTION; tmp[1] = (char)direction; usbprog_jtag_message(usbprog_jtag, tmp, 2); } static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag,unsigned char value) { char tmp[2]; tmp[0] = PORT_SET; tmp[1] = (char)value; usbprog_jtag_message(usbprog_jtag, tmp, 2); } #if 0 static unsigned char usbprog_jtag_get_port(struct usbprog_jtag *usbprog_jtag) { char tmp[2]; tmp[0] = PORT_GET; tmp[1] = 0x00; return usbprog_jtag_message(usbprog_jtag, tmp, 2); } #endif static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag,int bit, int value) { char tmp[3]; tmp[0] = PORT_SETBIT; tmp[1] = (char)bit; if (value == 1) tmp[2] = 0x01; else tmp[2] = 0x00; usbprog_jtag_message(usbprog_jtag, tmp, 3); } #if 0 static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit) { char tmp[2]; tmp[0] = PORT_GETBIT; tmp[1] = (char)bit; if (usbprog_jtag_message(usbprog_jtag, tmp, 2) > 0) return 1; else return 0; } #endif static void usbprog_jtag_tms_collect(char tms_scan) { tms_chain[tms_chain_index] = tms_scan; tms_chain_index++; } static void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag) { int i; /* LOG_INFO("TMS SEND"); */ if (tms_chain_index > 0) { char tmp[tms_chain_index + 2]; tmp[0] = WRITE_TMS_CHAIN; tmp[1] = (char)(tms_chain_index); for (i = 0; i < tms_chain_index + 1; i++) tmp[2 + i] = tms_chain[i]; usb_bulk_write(usbprog_jtag->usb_handle, 3, tmp, tms_chain_index + 2, 1000); tms_chain_index = 0; } } struct jtag_interface usbprog_interface = { .name = "usbprog", .execute_queue = usbprog_execute_queue, .speed = usbprog_speed, .init = usbprog_init, .quit = usbprog_quit };
"// Copyright 2013 The Chromium Authors. All rights reserved.\n// Use of this source code is governe(...TRUNCATED)

Dataset Card for TinyGiant

Dataset Summary

This dataset aims to provide a small but pretty viable base model dataset. Aimed to be able to train a model and teach it a viable amount of information about all tokens.

Languages

English (100%)

More soon...

Vocab Coverage (and other stats)

RWKV World Tokenizer

=====================================

enwiki.jsonl

documents: 46180

max context length: 54110

total tokens: 35413961

vocab coverage: 80.41%

file size: 159.56 megabytes

=====================================

stack_exchange.jsonl

documents: 71160

max context length: 20671

total tokens: 38983876

vocab coverage: 79.48%

file size: 148.36 megabytes

=====================================

webtext.jsonl

documents: 154557

max context length: 448

total tokens: 25027551

vocab coverage: 76.54%

file size: 109.57 megabytes

=====================================

code_documents.jsonl

documents: 23298

max context length: 263776

total tokens: 52397777

vocab coverage: 84.61%

file size: 187.14 megabytes

=====================================

stories.jsonl

documents: 25385

max context length: 1053

total tokens: 5552189

vocab coverage: 18.97%

file size: 23.57 megabytes

=====================================

text.jsonl

documents: 181030

max context length: 146988

total tokens: 350672227

vocab coverage: 95.67%

file size: 1329.66 megabytes

=====================================

vn.jsonl

documents: 190

max context length: 2217608

total tokens: 57891290

vocab coverage: 63.14%

file size: 209.89 megabytes

=====================================

jupyter_to_text.jsonl

documents: 9701

max context length: 45295

total tokens: 30927312

vocab coverage: 78.75%

file size: 112.12 megabytes

=====================================

stories_smart.jsonl

documents: 100676

max context length: 1137

total tokens: 23692169

vocab coverage: 23.55%

file size: 98.75 megabytes

=====================================

totals

documents: 612177

max context length: 2217608

tokens: 620558352

vocab coverage: 99.24%

size: 2378.63 megabytes

Downloads last month
0
Edit dataset card