Skip to content

Instantly share code, notes, and snippets.

View thinkclay's full-sized avatar

Clayton (McIlrath) Unicorn thinkclay

View GitHub Profile
/* FORM MODERNIZE */
input, select { vertical-align: middle; }
/* Buttons */
input[type="button"],
input[type="submit"],
button {
background: -webkit-linear-gradient(top, #ffffff, #dddddd);
background: -moz-linear-gradient(top, #ffffff, #dddddd);
background: linear-gradient(top, #ffffff, #dddddd);
@thinkclay
thinkclay / cookies.js
Created November 8, 2012 22:03
Cookie CRUD in JS
/**
* Custom Cookie Support for JS
*
* There aren't very many great ways of interacting with Cookies
* in either native JS or jQuery without the use of plugins
* so this snippet aims to give you quick and easy access
* to manipulate your cookies with native JS
*
* @author Clay McIlrath
* @link http://thinkclay.com/technology/add-edit-delete-cookies-with-javascript
@thinkclay
thinkclay / gist:4159108
Created November 28, 2012 04:57
building images from scratch
<?php
function wrap_text($txt, $color = 000000, $space = 4, $font = 2, $w = 300, $h = 300)
{
if (strlen($color) != 6)
$color = 000000;
$int = hexdec($color);
$fw = imagefontwidth($font);
$txt = explode("\n", wordwrap($txt, ($w / $fw) -2, "\n"));
$lines = count($txt);
@thinkclay
thinkclay / gist:5261627
Created March 28, 2013 08:32
RubyMotion - Notification when App enters Foreground
def viewWillAppear(animated)
@foreground_observer = App.notification_center.observe UIApplicationWillEnterForegroundNotification do |notification|
// call method here
end
end
def viewWillDisappear(animated)
App.notification_center.unobserve @foreground_observer
end
@thinkclay
thinkclay / create_screen.rb
Created April 12, 2013 13:06
RubyMotion example of keyboard handlers
Teacup::Stylesheet.new :create_screen do
# Input Fields
style :input_text_wrapper,
left: 24,
image: UIImage.imageNamed('ui-textfield-normal.png'),
userInteractionEnabled: true,
width: 249
style :input_text_type,
@thinkclay
thinkclay / gist:5433225
Created April 22, 2013 08:18
MongoDB M101 HW 3.1 in Ruby
require 'mongo'
require 'json'
include Mongo
@client = MongoClient.new('localhost', 27017)
@db = @client['school']
@students = @db['students']
@students.find().each { |student|
@thinkclay
thinkclay / ftp.php
Created August 3, 2013 00:53
A simple PHP FTP class to list and download files
<?php
class FTP {
/**
* Download() performs an automatic syncing of files and folders from a remote location
* preserving folder and file names and structure
*
* @param $local_dir: The directory to put the files, must be in app path and be writeable
* @param $remote_dir: The directory to start traversing from. Use "." for root dir
@thinkclay
thinkclay / gist:8857122
Created February 7, 2014 03:49
Navicat Function to update Wordpress Post dates
BEGIN
SET @ID = 1;
WHILE @ID < 100 DO
UPDATE wp_posts SET comment_count = (SELECT COUNT('ID') FROM wp_comments WHERE comment_post_ID = @ID) WHERE ID = @ID;
SET @ID = @ID + 1;
END WHILE;
UPDATE wp_posts SET post_date = (SELECT FROM_UNIXTIME(post_time));
UPDATE wp_posts SET post_date_gmt = (SELECT FROM_UNIXTIME(post_time));
@thinkclay
thinkclay / aes.go
Created March 23, 2014 13:48
GO: AES Example
package main
import (
"crypto/aes"
"crypto/cipher"
"fmt"
)
func main() {
input := []byte("this is a test")
@thinkclay
thinkclay / aes.rb
Created March 23, 2014 13:49
Ruby: AES Example
require 'uri'
require 'net/http'
require 'net/https'
require 'base64'
input = "this is a test"
iv = "532b6195636c6127"
key = "532b6195636c61279a010000"
puts "Input: [" + input.bytes.join(" ") + "]"