Skip to content

Instantly share code, notes, and snippets.

View vamdt's full-sized avatar

vamdt vamdt

  • Foggy Beijing
View GitHub Profile
@jed
jed / uniqlo_needs_u.md
Last active August 29, 2015 14:16
UNIQLO NEEDS U!

UNIQLO logo

tl;dr: The [UNIQLO USA][] e-commerce team is looking for a design-oriented developer skilled in the arts of modern markup and style, but also comfortable with some PHP and JavaScript.


In this position, you will:

  • Create end-to-end responsive mockups of UNIQLO landing pages for upcoming product lines.
  • Work in-house with the visuals team to design experiences and assets that scale well across device sizes.
@metaskills
metaskills / gist:977846
Created May 18, 2011 01:52
If your not returning ruby primitives and other objects that know how to respond to #as_json from #as_jons - Your doing it wrong.
class User < ActiveRecord::Base
has_many :columns
def as_json(options={})
attributes.slice(:id, :email, :uuid).merge(:columns => columns)
end
end
class Column < ActiveRecord::Base
belongs_to :user
has_many :boxes
@ksarna
ksarna / profiling_tool.rb
Created November 23, 2011 20:10
Profiling rails requests with ruby-prof
# You can use this class in your console. For example
# p = ProfilingTools.new
# p.profiled_request(:controller => :welcome, :action => :index)
# this will profile whole application stack and save file in your tmp/profiler folder
# You can also use +request+ method just to see the output for example:
#
# p.request(:controller => :offers, :action => :index)
#
# p.response.body
# p.response.cookies # and so on
@conrad-vanl
conrad-vanl / authManager.coffee
Last active October 10, 2015 19:48
Basic Auth manager for Ember
App.authManager = Ember.StateManager.create
# The "stack" contains the currently logged-in user
stack: []
# Callbacks to be ran once the user is authenticated
callbacks: {}
# Grabs the current auth object and returns it
# If callback argument is given, will run the callback function with current auth object as first argument
@kara-ryli
kara-ryli / yui3-serialize-form.js
Created February 18, 2011 02:26
Serialize a form into a query string with YUI3
YUI().use('node', 'array-extras', 'querystring-stringify', function (Y) {
var form = Y.one('FORM_SELECTOR'), query;
query = Y.QueryString.stringify(Y.Array.reduce(Y.one(form).all('input[name],select[name],textarea[name]')._nodes, {}, function (init, el, index, array) {
init[el.name] = el.value;
return init;
}));
console.log(query);
});
@tareqabedrabbo
tareqabedrabbo / Pipelined SET.java
Created May 3, 2011 20:59
Redis Pipelines and Transactions
Pipeline pipeline = jedis.pipelined();
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
pipeline.set("" + i, "" + i);
}
List<Object> results = pipeline.execute();
long end = System.currentTimeMillis();
System.out.println("Pipelined SET: " + ((end - start)/1000.0) + " seconds");
@azymnis
azymnis / KMeansJob.scala
Created October 23, 2014 23:07
K-Means in scalding
import com.twitter.algebird.{Aggregator, Semigroup}
import com.twitter.scalding._
import scala.util.Random
/**
* This job is a tutorial of sorts for scalding's Execution[T] abstraction.
* It is a simple implementation of Lloyd's algorithm for k-means on 2D data.
*
* http://en.wikipedia.org/wiki/K-means_clustering
@wataru420
wataru420 / addUser
Created February 7, 2012 03:54
Jenkins init script for centos
/usr/sbin/groupadd -g 30119 jenkins
/usr/sbin/useradd -u 30119 -g jenkins jenkins
mkdir /home/jenkins
chown -R jenkins. /home/jenkins
@brentertz
brentertz / ab.sh
Created March 27, 2012 14:35
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."