Skip to content

Instantly share code, notes, and snippets.

@xarimanx
xarimanx / pub_sub.js
Created July 26, 2013 07:31
Pub/sub js plugin
/*
jQuery pub/sub plugin by Peter Higgins ([email protected])
Loosely based on Dojo publish/subscribe API, limited in scope. Rewritten blindly.
Original is (c) Dojo Foundation 2004-2010. Released under either AFL or new BSD, see:
http://dojofoundation.org/license for more information.
*/
@xarimanx
xarimanx / youtube-img.txt
Created August 5, 2013 07:48
Youtube thumbnail images
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
{
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"ignored_packages":
[
"Vintage"
],
"tab_size": 2,
"translate_tabs_to_spaces": true,
"use_simple_full_screen": false,
@xarimanx
xarimanx / upload_file_by_curl.txt
Created August 19, 2013 13:23
Upload file by curl
curl [url] -F '[param_name]=@[file_path];type=[mime-type]' -F '[other_params](optional)'
@xarimanx
xarimanx / antiIe.txt
Created August 30, 2013 11:02
antiIE
<!--[if IE]>
<meta http-equiv="refresh" content="0;url=http://www.google.com/chrome/" />
<![endif]-->
/[if IE]
<meta http-equiv="refresh" content="0;url=http://www.google.com/chrome/" />
@xarimanx
xarimanx / deploy.rb
Created September 27, 2013 06:57 — forked from ryancheung/deploy.rb
require "rvm/capistrano" # Load RVM's capistrano plugin.
require "bundler/capistrano"
set :rvm_ruby_string, '1.9.3'
set :rvm_type, :user # Literal ":user"
set :application, "blog_test"
set :repository, "[email protected]:ryancheung/blog.git"
set :scm, :git
@xarimanx
xarimanx / hide.js
Created December 18, 2013 06:09
Use jQuery to hide a DIV when the user clicks outside of it
$(document).mouseup(function (e)
{
var container = $("YOUR CONTAINER SELECTOR");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
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
@xarimanx
xarimanx / jq.xpath.js
Created February 21, 2014 06:30
find by xpath
(function($) {
$.xpath = function(exp, ctxt) {
var item, coll = [],
result = document.evaluate(exp, ctxt || document, null, 5, null);
while (item = result.iterateNext())
coll.push(item);
return $(coll);
}