Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. Newton

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. Newton
View GitHub Profile
@thinkphp
thinkphp / gist:5070420
Created March 2, 2013 10:23
Event Delegation on CUI Library
var delegate = cui.event.delegate,
dom = cui.dom,
ready = cui.ready;
ready(function(){
delegate(dom.select("#menu"), 'li a', 'click', function( e ){
if(window.console) console.log(e.target)
@thinkphp
thinkphp / gist:5073272
Created March 2, 2013 21:01
Instagram Search based on cuba.js
(function(){
var timer;
function instaSearch() {
//add loading
cuba.select("#s").addClass("loading")
var q = cuba.select("#s").value[0].value
@thinkphp
thinkphp / gist:5075209
Created March 3, 2013 07:36
Instagram Seach using CUI2 AMD Style.
require(["cui","dom","event","ajax"], function(cui, dom, event, ajaxobj){
var sfield = dom.select("#s"),
container = dom.select("#photos"),
timer;
function instaSearch() {
dom.addClass(sfield, "loading")
@thinkphp
thinkphp / gist:5075226
Created March 3, 2013 07:44
Instagram Search based on CUI2 AMD Style, but with Keydown method to the Element.
require(["cui","dom","event","ajax"], function(cui, dom, event, ajaxobj){
var sfield = dom.select("#s"),
container = dom.select("#photos"),
timer;
function instaSearch() {
dom.addClass(sfield, "loading")
@thinkphp
thinkphp / gist:5106626
Created March 7, 2013 09:06
Autosuggest widget based on CUI2 AMD Style.
require(["ready", "dom", "autosuggest"], function(app, dom, widget){
var Autosuggest = widget.autosuggest
var suggestions = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
@thinkphp
thinkphp / gist:5107438
Last active August 16, 2023 12:14
Luhn Python checksum for credit card validation
#Luhn Python checksum for credit card validation
import sys
def luhn(n):
sum = 0
alt = 0
i = len(n) - 1
@thinkphp
thinkphp / gist:5110833
Created March 7, 2013 19:09
Creating sha-1 on Node.js.
var crypto = require('crypto');
function sha1( data ) {
var generator = crypto.createHash('sha1');
generator.update( data )
return generator.digest('hex')
}
console.log( sha1('adrian') )
@thinkphp
thinkphp / gist:5114543
Created March 8, 2013 06:13
A simple static File Server.
var sys = require("sys"),
http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs");
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname;
var filename = path.join(process.cwd(), uri);
@thinkphp
thinkphp / gist:5176095
Last active December 15, 2015 00:49
An interface that provides Bing Search using Sinatra.
class MyApp < Sinatra::Base
get '/' do
@title = "Home"
erb:index
end
@thinkphp
thinkphp / gist:5177833
Created March 16, 2013 19:10
config.ru
require 'rubygems'
require 'bundler'
Bundler.require
require './app.rb'
run MyApp