Skip to content

Instantly share code, notes, and snippets.

# used to alter columns in postgresql
module AlterColumn
def alter_column(table_name, column_name, new_type, mapping, default = nil)
drop_default = %Q{ALTER TABLE #{table_name} ALTER COLUMN #{column_name} DROP DEFAULT;}
execute(drop_default)
# puts drop_default
base = %Q{ALTER TABLE #{table_name} ALTER COLUMN #{column_name} TYPE #{new_type} }
if mapping.kind_of?(Hash)
contains_else = mapping.has_key?("else")
@okaq
okaq / godart.txt
Created May 17, 2013 00:05
Minimum Golang/Dartlang HTTP
// webserver.go
package main
import (
"fmt"
"net/http"
// "net/url"
)
func AbHandler(w http.ResponseWriter, r *http.Request) {
@westwickfarrow
westwickfarrow / es.sh
Created July 13, 2012 10:07
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo add-apt-repository ppa:dlecan/openjdk
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.7.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@dpoeschl
dpoeschl / gist:7924130
Created December 12, 2013 06:56
Could be better, but I had to have one that showed the words as they're spoken. For the inspiration: https://gist.github.com/fekberg/bac40e784113dd75c03e
// Expanded on Filip Ekberg's gist: https://gist.github.com/fekberg/bac40e784113dd75c03e
// See his tweet @fekberg for more https://twitter.com/fekberg/status/410964845870071808
// Not perfect, but still amusing.
using System;
using System.Media;
using System.Speech.Synthesis;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
@ianjosephwilson
ianjosephwilson / runlint.py
Created August 2, 2016 21:15
Testing out the mini racer v8 interface with Douglas Crockford's jslint.js from http://www.jslint.com/.
"""
Testing out the py mini racer v8 interface with Douglas Crockford's jslint.js from http://www.jslint.com/.
"""
import sys
from py_mini_racer import py_mini_racer
HTML_PAGE_FORMAT = """<!DOCTYPE html>
<head>
<meta charset="utf-8">
// Simple spreadsheet, with first sheet containing form submission repsonses
// when the form is submitted:
// 1) grab the latest response,
// 2) post it to a third party service via an HTTP POST
function testWebhook() {
var ss = SpreadsheetApp.openById(SPREADSHEET_ID);
var form=ss.getSheets()[0];
var lr=form.getLastRow();
var el=form.getRange(lr,2,1,1).getValue();
var t=el;
@kaylarose
kaylarose / RaphaelJSShapeDrawingApp.html
Created November 11, 2010 21:07
A Simple Vector Shape Drawing App with RaphaelJS and jQuery
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script src="http://yandex.st/raphael/1.5.2/raphael.min.js"></script>
<script>
/**
* A Simple Vector Shape Drawing App with RaphaelJS and jQuery
* copyright 2010 Kayla Rose Martin - Licensed under the MIT license
* Inspired by http://stackoverflow.com/questions/3582344/draw-a-connection-line-in-raphaeljs
**/
@tony-landis
tony-landis / pdo-adodb-singleton-refactor.class.php
Created December 3, 2008 07:44
PHP PDO Singleton w/AdoDB backwards compatable
<?php
/**
* PDO SINGLETON CLASS, ADODB ENABLED
*
* @author Tony Landis
* @link http://www.tonylandis.com
* @license Use how you like it, just please don't remove or alter this PHPDoc
*/
class sdb
{
@builtbylane
builtbylane / angular-remove-white-space-filter.js
Created October 30, 2013 18:43
AngularJS – filter: removes white space from text. useful for html values that cannot have spaces
/**
* Description:
* removes white space from text. useful for html values that cannot have spaces
* Usage:
* {{some_text | nospace}}
*/
app.filter('nospace', function () {
return function (value) {
return (!value) ? '' : value.replace(/ /g, '');
@mloberg
mloberg / gist:2852153
Created June 1, 2012 13:28
MySQL Slow Query Log Analyzer
#!/usr/bin/php
<?php
/**
* The Analyzer class.
*/
class Analyzer {
private $fp;