Skip to content

Instantly share code, notes, and snippets.

View RyanDawkins's full-sized avatar
🏠
Working from home

Ryan Dawkins RyanDawkins

🏠
Working from home
  • Amazon Web Services
  • Virtual, US
View GitHub Profile
@RyanDawkins
RyanDawkins / promise.js
Created December 16, 2015 03:03
Basic promise implementation
function promise() {
// values to be passed on
this._value = undefined;
this._error = undefined;
this._callback = undefined;
}
promise.prototype.fullfill = function fullfill(value, error) {
@RyanDawkins
RyanDawkins / decrypt.py
Created October 29, 2014 23:12
Uses Character Frequency Determine the key by a given string that has 1 bit xor
#!/usr/bin/python
encrypted_text = [0x1b,0x37,0x37,0x33,0x31,0x36,0x3f,0x78,0x15,0x1b,0x7f,0x2b,0x78,0x34,0x31,0x33,0x3d,0x78,0x39,0x78,0x28,0x37,0x2d,0x36,0x3c,0x78,0x37,0x3e,0x78,0x3a,0x39,0x3b,0x37,0x36]
class Node_Hex:
value = None
frequency = 0
adjacent = None
def __init__(self, value):
@RyanDawkins
RyanDawkins / rest_controller.rb
Created October 26, 2014 18:26
Generic Ruby REST controller for rails
class RestController < ApplicationController
before_filter :find, :only => [:show, :update, :delete]
def index
@objects = get_class().all
render json: @objects
end
def show
@RyanDawkins
RyanDawkins / api.php
Created August 5, 2014 05:44
CRUD Controller for API
<?php
abstract class Controller_Api extends \Fuel\Core\Controller_Rest
{
/**
* The model class for the orm
* @var string
*/
protected $orm_model;
@RyanDawkins
RyanDawkins / ieplaceholder.js
Last active December 20, 2015 18:48
Script to allow placeholder in IE
/* <![CDATA[ */
$(function() {
var input = document.createElement("input");
if(('placeholder' in input)==false) {
$('[placeholder]').focus(function() {
var i = $(this);
if(i.val() == i.attr('placeholder')) {
i.val('').removeClass('placeholder');
if(i.hasClass('password')) {
i.removeClass('password');