Skip to content

Instantly share code, notes, and snippets.

View baisong's full-sized avatar

Oren Robinson baisong

View GitHub Profile
def what():
i += 1
@baisong
baisong / README.md
Created July 5, 2011 12:17 — forked from rgabo/README.md
CoffeeScript / Node.js - ticksort

Node.js ticksort in CoffeeScript!

Beating your sleepsort by magnitudes! Takes only SUM(argv) ticks and does not overflow the stack either. Fork the gist if you can reduce the size of ticksort.coffee.

@baisong
baisong / profile-picture-link-fix.js
Created July 13, 2011 17:30
A little jQuery hack to overcome a drupal views issue http://drupal.org/node/750172
@baisong
baisong / main.zh.go
Created March 9, 2012 20:31
gosofunky mandarin chinese translation
/*
* gosofunky - demos 3 'functional programming' ways to use functions in go
*/
package main
import "fmt"
/**
* Way #1: 函数当作输入(引数)和输出(传出值)
@baisong
baisong / curltweet.sh
Created March 20, 2012 15:06
tweet from your command line
#!/bin/bash
#Twitter status update bot by http://360percents.com
#Author: Luka Pusic <pusic93@gmail.com>
#Modified a little bit by oren
#REQUIRED PARAMS
twitteremail="your@email.here"
password="pizzamonkey"
tweet="$*" #must be less than 140 chars
@baisong
baisong / hanoi.dart
Created May 10, 2012 15:49
Implements Towers of Hanoi in Dart
/**
* Implements Towers of Hanoi Game
* @see http://en.wikipedia.org/wiki/Towers_of_hanoi
*/
main() {
// Formats a move to output.
String say(String from, String to) => "move $from -> $to";
// Makes a move and recursively triggers next moves, if any.
hanoi(int discs, String a, String b, String c) {
@baisong
baisong / db-remove-error-line.sh
Created May 15, 2012 19:07
Imports a huge mysqldump (.sql) file by removing a one-line error.
# db-remove-error-line.sh
# Imports a huge mysqldump (.sql) file by removing a one-line error.
# @see http://forums.mysql.com/read.php?103,411576,411576 (Error that inspired this workaround)
# @see http://dev.mysql.com/doc/refman/5.1/en/news-5-1-24.html (release notes of MySQL fix)
# [or] 2012-05-15
# Config - Replace this number with the number an error occurs on.
ERRORLINE='100000'
# Names filepaths to use.
@baisong
baisong / 2012-05-23 Constant Contact Crap.html
Created May 23, 2012 14:47
A horrible 3x2 html table of html tables for email...
<table width="100%" cellspacing="0" cellpadding="5" border="0" bgcolor="#FFFFFF"id="textEdit" style="padding-top: 15px; padding-bottom: 15px; background-color: #ffffff;">
<tbody>
<tr>
<td style="padding-left: 15px; text-align: center;" valign="top"align="center">
<div>
<div style="text-align: left;" align="left">
<div>
<div style="text-align: center;" align="center"><span style="font-family: Verdana, Geneva; color: #56aebf; font-size: 16pt;" color="#56aebf" size="5"face="Verdana, Geneva"><b>Community Innovation: Judging and SBANE</b></span></div>
<div style="text-align: center;" align="center"><span style="color: #56aebf; font-family: Verdana, Geneva; font-size: 18pt;" color="#56aebf" size="5"face="Verdana, Geneva"><b>&nbsp;</b></span></div>
<p style="font-size: 12pt; margin-top: 0px; margin-bottom: 0px;"><span style="font-family: Verdana, Geneva;">After <strong>5,400+</strong> reads of online applications, <strong>150+</stron
@baisong
baisong / _custom_simple_mail.php
Created May 31, 2012 16:48
Drupal 7 function to send simple email to developer or administrator.
<?php
/**
* Sends a simple email.
* [or] Tested on 2012-05-31 using Drupal 7.12
*
* Usage:
* 1) Paste all the below code into your module or include
* 2) Configure the two @FIXME's.
* 3) Visit /_custom_simple_mail to get an email.
*
@baisong
baisong / import.php
Created June 12, 2012 15:08
Example import using fgetcsv
<?php
if (($handle = fopen($filepath, "r")) == FALSE) {
echo ("Error loading CSV file '" . $filepath . "'. Import failed.";
return;
}
echo 'Processing CSV file for import...';
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$columns = count($data);