Skip to content

Instantly share code, notes, and snippets.

@alexey-bass
alexey-bass / compare.js
Created July 30, 2011 14:03
JavaScript version compare
/**
* Simply compares two string version values.
*
* Example:
* versionCompare('1.1', '1.2') => -1
* versionCompare('1.1', '1.1') => 0
* versionCompare('1.2', '1.1') => 1
* versionCompare('2.23.3', '2.22.3') => 1
*
* Returns:
@aeurielesn
aeurielesn / gist:2511005
Created April 27, 2012 17:23
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,
@hoffrocket
hoffrocket / parhttp.py
Created August 28, 2012 00:29
Python parallel http requests using multiprocessing
#!/usr/bin/env python
from multiprocessing import Process, Pool
import time
import urllib2
def millis():
return int(round(time.time() * 1000))
def http_get(url):
@danbarua
danbarua / gist:3528413
Created August 30, 2012 13:21
RabbitMQ reliable consumer pattern
while (_isRunning)
{
try
{
if (channel == null || consumer == null)
{
try
{
_connection = factory.CreateConnection();
channel = _connection.CreateModel();
@ryanfitz
ryanfitz / golang-nuts.go
Created December 2, 2012 22:45
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active September 8, 2025 14:36
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add [email protected]:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@idiom
idiom / gist:5716494
Last active December 6, 2022 10:29
Building Mozilla NSS (Network Security Services) on Windows
1. Download & Install Visual Studio 2010 - Version able to compile C++
2. Download and Install Mozilla build files http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe
3. Download the latest NSS package from: http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/
Download the tar with npsr
4. Create a directory C:\src
5. Extract nss to c:\src
So this will end up looking like c:\src\nss-3.15
6. Run the Mozilla build shell: C:\mozilla-build\start-msvc10.bat
7. Create the required env variables
Type: export OS_TARGET="WINNT"
@user20161119
user20161119 / findingapirequest.json
Created January 1, 2014 08:31
ebay finding api request json
{
"jsonns.xsi": "http://www.w3.org/2001/XMLSchema-instance",
"jsonns.xs": "http://www.w3.org/2001/XMLSchema",
"jsonns.tns": "http://www.ebay.com/marketplace/search/v1/services",
"tns.findItemsByKeywordsRequest": {
"keywords": "great white shark tooth",
"categoryId": [
"15917"
],
"paginationInput": {
@jaicab
jaicab / responsive-video.css
Last active December 11, 2024 20:06
Pure CSS solution for embed videos with an aspect ratio of 16:9
.video-container {
position: relative;
padding-bottom: 56.25%; /*16:9*/
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-container iframe,
.video-container object,
@carolineschnapp
carolineschnapp / gist:9122054
Last active October 25, 2024 16:31
Order form to use in a page or collection template.
{% comment %}
Source: https://gist.github.com/carolineschnapp/9122054
If you are not on a collection page, do define which collection to use in the order form.
Use the following assign statement, replace 'your-collection-handle-here' with your collection handle.
{% assign collection = collections.your-collection-handle-here %}
Use the assign statement outside of this comment block at the top of your template.
{% endcomment %}
{% paginate collection.products by 100 %}