Skip to content

Instantly share code, notes, and snippets.

View ryngonzalez's full-sized avatar

✨ Kathryn Gonzalez ✨ ryngonzalez

View GitHub Profile
namespace :db do
desc "load data from csv"
task :load_csv_data => :environment do
require 'fastercsv'
FasterCSV.foreach("importdata/tarife.csv", :headers => true, :col_sep => ',') do |row|
Anbieter.find_or_create_by_name(
:name => row['Anbieter_Name']
:hotline => row['Hotline'],
:email => row['Email']
@jh3
jh3 / Capfile
Created November 1, 2010 18:29
An example Capfile for drupal-deploy
require 'rubygems'
require 'drupal-deploy'
load File.join(File.dirname(__FILE__), 'config', 'lib', 'deploy')
# The name of your Drupal site
set :application, "sandbox"
# The user that will own the files directory
set :web_user, "apache"
@getify
getify / gist:675496
Created November 13, 2010 17:18
detecting if flash plugin is installed
var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) != false));
@amw
amw / database.yml
Created December 21, 2010 16:12
Standard rails database.yml with additional definition of live database
development:
adapter: mysql2 # must =~ /mysql/
database: adamDb # required
username: your_user
password: keep_secret
live:
ssh_user: # optional, use if live system user differs from your dev user
host: example.com # required, can be IP
adapter: mysql2 # must =~ /mysql/
require "chunky_png"
require "base64"
module Sass::Script::Functions
def background_noise(kwargs = {})
opts = {}
Sass::Util.map_hash({
"intensity" => [0..1, "", :Number, Sass::Script::Number.new(0.5) ],
"opacity" => [0..1, "", :Number, Sass::Script::Number.new(0.08)],
"size" => [1..512, "px", :Number, Sass::Script::Number.new(200) ],
@necolas
necolas / snippet.js
Created June 14, 2011 20:36
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@adeel
adeel / UITextField+withFrame.h
Created July 28, 2011 19:00
UITextField category for conveniently adding text fields inside frames with padding.
//
// UITextField+withFrame.h
//
#import <Foundation/Foundation.h>
@interface UITextField (withFrame)
+ (UITextField *)textFieldWithFrame:(CGRect)frame
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@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