Skip to content

Instantly share code, notes, and snippets.

@wesleyfsmith
wesleyfsmith / 0_reuse_code.js
Created March 5, 2014 22:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@wesleyfsmith
wesleyfsmith / javascript_resources.md
Created March 5, 2014 22:16 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@wesleyfsmith
wesleyfsmith / css_resources.md
Created March 5, 2014 22:16 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@wesleyfsmith
wesleyfsmith / ParentFragment.java
Created May 1, 2013 17:15
Asynctask tracking.
///////////////////////////////////////////////////////////////////////////
// AsyncTask
///////////////////////////////////////////////////////////////////////////
public final void addTask(AsyncTask task) {
asyncTasks.add(task);
}
public void addAndStartTask(AsyncTask task) {
addAndStartTask(task, null);
public void selectTab(int itemPosition) {
//hide whatever was previously showing
hideCurrentFragment();
currentTab = availableTabs.get(itemPosition);
//haven't determined where to go yet
if (currentTab == null) {
return;
}
public void showFragment(ParentFragment fragment, int transition, int containerViewId) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
if (containerViewId == NO_CONTAINER) {
containerViewId = R.id.activity_root;
}
if (currentFragment == null) {
fragmentTransaction.add(containerViewId, fragment);
} else {
fragmentTransaction.replace(containerViewId, fragment);
}
@wesleyfsmith
wesleyfsmith / gist:6042910
Created July 19, 2013 22:47
Course Modules crash.
07-19 16:46:22.009 23753-23753/com.instructure.candroid E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at com.instructure.candroid.fragment.CourseModulesFragment$GetModuleItemsAsyncTask.onPostExecute(CourseModulesFragment.java:892)
at com.instructure.candroid.fragment.CourseModulesFragment$GetModuleItemsAsyncTask.onPostExecute(CourseModulesFragment.java:842)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
01000000018afc335f782a5bcc907f274d9fff16656b9ab2eb13b82d5afb46e9866cf2ba0700000000fd2a01483045022100f47a42a2ecd998128adc4159c312552707dbcf0ff883c6fec65821d218e6f77302206e9b9d601443a59acb8b0129d2f8fe365ee7cd82631c42e03e80cf4a293dd1fb01473044022023e297732b6ede62c770b9675ab9c04e1c861aabe6bb2569e8f0857fa480d6bd022024cab55137dbbef3031d587b24974e10c0ce52abb9aa944803266370ef1cbb3001004c966352210293446c54a24a865a2f663a35ac21f6872e45aae8980fce121ac95e9c4224916e2103515c07520b1679ad67865a5d8e4d42c4bbe56e9daa42fe53bd161c0ac9e4aacc21032372aa111bf47cbfd64ab1f4b9714dafe8db01df9f9805467990bf69bb0ca54b53ae6704a954ee5ab275210293446c54a24a865a2f663a35ac21f6872e45aae8980fce121ac95e9c4224916eac68ffffffff01043906000000000017a914a9974100aeee974a20cda9a2f545704a0ab54fdc870b02ed5a
64fa73f93e2660ea0a52eaf793b272d92624af74c8341cdd57ddad3961f8494f
var hashType = bitcoin.Transaction.SIGHASH_ALL;
var signatureHash = tx.hashForSignature(0, redeemScript, hashType);
console.log('Sig hash: ', signatureHash.toString('hex'));
const redeemScriptSig = bitcoin.script.scriptHash.input.encode([
seller.sign(signatureHash).toScriptSignature(hashType),
buyer.sign(signatureHash).toScriptSignature(hashType),
bitcoin.opcodes.OP_FLASE
], redeemScript)