Skip to content

Instantly share code, notes, and snippets.

View jamesyang124's full-sized avatar

James Yang jamesyang124

  • HTC
  • Richmond, California
View GitHub Profile
@emad-elsaid
emad-elsaid / coloring.rb
Created March 17, 2014 12:47
Create a Waving ColorSpace using ruby
#!/usr/bin/env ruby
require 'gosu' # gem install gosu
$dimension, $squares = 200, 20
$size = $dimension / $squares
class Entity
def initialize(x,y, win)
@pos = {x:$dimension/$squares*x, y:$dimension/$squares*y}
@last_update = @update_limit = 4
@color = {h:360/$squares.to_f*x, s:1/$squares.to_f*y}
@color_dir = {h:360/$squares.to_f,s:1/$squares.to_f}
@jbynum
jbynum / pow-restart
Created January 9, 2012 23:48
Shell-script to restart Pow when it stops reponding
#!/bin/bash
# Restarts Pow when DNS fails to resolve
lsof | grep 20560 | awk '{print $2}' | xargs kill -9
launchctl unload ~/Library/LaunchAgents/cx.pow.powd.plist
launchctl load ~/Library/LaunchAgents/cx.pow.powd.plist
@manoamaro
manoamaro / gist:3000167
Created June 26, 2012 23:36
Bellman-Ford algorithm
class Vertice
attr_accessor :predecessor, :d, :name
def initialize(n)
@name = n
end
end
class Edge
attr_accessor :source, :destination, :w
def initialize(s,d,w)
@soupmatt
soupmatt / zzz_pow.conf
Created July 1, 2011 13:51
Apache reverse proxy config for pow
<VirtualHost *:80>
ServerName pow
ServerAlias *.dev
ServerAlias *.xip.io
ProxyPass / http://localhost:20559/
ProxyPassReverse / http://localhost:20559/
ProxyPreserveHost On
</VirtualHost>
@asaaki
asaaki / unary-oddities.rb
Created July 21, 2011 17:30
Ruby Unary operator overloading and it's oddities
### The 4 unaries are: + - ~ !
### If you really found more, tell me ;o)
class Foo
def +@
puts "unary plus (in front of object) / without param"
end
def -@(a=42)
# please tell me, how could I pass an argument to an unary operation?
# but it's possible to define arguments, curious ...

Getting Cassandra and OpsCenter to run on OSX using Docker

Getting Docker installed

Why not make life easy...? Install Homebrew

The 'brew' package lets you install applications through the commandline, making compiling and setting up new apps a breeze.

Since docker cannot run on osx natively, we will need to build a virtual machine

@Matho
Matho / refinerycms_nginx_proxy_cache
Last active September 9, 2016 20:20
Refinery CMS - Nginx proxy_cache instead of Rack:Cache
Refinery CMS:
Caching images generated by Dragonfly with Nginx cache_proxy instead of Rack:Cache
Before:
Static image served by Nginx: 4409.40 req/sec (mean)
Dragonfly generated images from Rack:Cache: 286.66 req/sec (mean)
After:
Dragonfly generated images from Nginx proxy_cache: 4099 req/sec (mean)
@pstadler
pstadler / pow-and-apache.md
Last active November 16, 2016 19:39
Running Pow and Apache

Running Pow and Apache

Pow is a tool for mapping your web apps and their ports to a .dev domain locally. This guide shows how to setup Pow to run alongside Apache.

# Setup user home (http://localhost/~USERNAME/)
echo "<Directory \"/Users/$USER/Sites/\">
  Options Indexes MultiViews FollowSymLinks
  AllowOverride All
 Order allow,deny
@maxjakob
maxjakob / urlEncode-example.scala
Created May 18, 2012 10:46
DBpedia Spotlight Web Service example call
val exampleText = "Residential Search List Page - Mortgage advice from SPF, WT.conv, Mortgage Advice From SPF, WT.tx_e, conv, WT.dl, 85], selector:a[href*=mortgages]}]},"
val urlEncoded = java.net.URLEncoder.encode(exampleText, "utf-8")
val url = new java.net.URL("http://spotlight.dbpedia.org/rest/annotate")
val data = "text=" + urlEncoded + "&support=10&confidence=0.2"
val conn = url.openConnection
conn.setDoOutput(true)
val out = new java.io.OutputStreamWriter(conn.getOutputStream)
out.write(data)
@ArthurN
ArthurN / i18n.rb
Created December 2, 2013 01:07
Monkey-patch Rails I18n.translate to see what keys ActiveModel is trying to use.
#initializers/i18n.rb
I18n.module_eval do
class << self
def translate_with_puts(*args)
Rails.logger.debug "#{args}"
old_translate(*args)
end
alias :old_translate :translate
alias :translate :translate_with_puts
end