Skip to content

Instantly share code, notes, and snippets.

View johnjohndoe's full-sized avatar

Tobias Preuss johnjohndoe

View GitHub Profile
@flackou
flackou / mysql2_wait_timeout.rb
Created December 23, 2011 13:04
Testing mysql2 wait_timeout param
require 'rubygems'
gem 'mysql2'
gem 'activerecord', '3.1.1'
require 'active_record'
# http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_wait_timeout
MYSQL_WAIT_TIMEOUT_MAX = 2147483
# Testing the remote db connection after a 60s sleep
def test_connection(extra_conf = {})
@spadgos
spadgos / gist:1427918
Created December 3, 2011 19:38
Broken lift
Disclaimer: We are not affiliated with GitHub in any way!
Random Hacks of Kindness Berlin, Dec 2011 #RHoKbln
Project: Broken Lifts
Next steps:
Backend team
create database with static data
@sra448
sra448 / tail.py
Created November 9, 2011 16:44
sublime text 2 command for tailing and greping the rails logfile
import sublime, sublime_plugin, os
class TailCommand(sublime_plugin.TextCommand):
def run(self, edit):
from datetime import datetime
filtertext = "FLO"
# open sublime console
self.view.window().run_command("show_panel", { "panel": "console", "toggle": "true" })
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@jcf
jcf / email_validator.rb
Created September 2, 2011 10:48 — forked from stauntonknight/email_validator.rb
Rails 3 Email Validator
require 'mail'
class EmailValidator < ActiveModel::EachValidator
attr_reader :record, :attribute, :value, :email, :tree
def validate_each(record, attribute, value)
@record, @attribute, @value = record, attribute, value
@email = Mail::Address.new(value)
@tree = email.__send__(:tree)
@coldnebo
coldnebo / Default (Linux).sublime-keymap
Created August 10, 2011 23:20
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]
@rajiv-singaseni
rajiv-singaseni / MainActivity.java
Created August 1, 2011 09:32
An Android activity that will demonstrate basic authentication mechanism
package com.webile.basicauth;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
@jpantuso
jpantuso / osx_lion_rail_setup.md
Created July 27, 2011 19:51
Setup OS X 10.7 w/ homebrew, oh-my-zsh, rvm, rails, and MySQL
@ptrv
ptrv / gitignore-rules-adder.py
Last active September 25, 2015 04:57
Script for adding ignore rules to gitignore files.
#!/usr/bin/python
# Script for adding ignore rules to gitignore files.
#
# Peter Vasil
# Date: 2011-03-11
import sys
from optparse import OptionParser
@ptrv
ptrv / CreateVersionNumber.py
Last active September 24, 2015 23:38
generating version code from string
#!/usr/bin/python
# Script for generating a software version code(hex) from a version string.
#
# Usage e.g $ python CreateVersionNumber.py 1.4.2"
#
# Peter Vasil
# Date: 2011-02-15
from optparse import OptionParser