Skip to content

Instantly share code, notes, and snippets.

@alexlib
alexlib / split_image_4_quarters.py
Last active May 16, 2021 14:04
Python code using PIL to split the image into 4 quarters. useful for the four-view image splitter 3D-PTV project on http://www.openptv.net
from PIL import Image
import os
import glob
import numpy as np
def crop(im, height, width):
# im = Image.open(infile)
imgwidth, imgheight = im.size
rows = np.int(imgheight/height)
/* SF OAuth request, redirect to SF login */
app.get('/oauth/auth', function(req, res) {
res.redirect(oauth2.getAuthorizationUrl({scope: 'api id web'}));
});
/* OAuth callback from SF, pass received auth code and get access token */
app.get('/oauth/callback', function(req, res) {
var conn = new jsforce.Connection({oauth2: oauth2});
var code = req.query.code;
conn.authorize(code, function(err, userInfo) {
@riteshmodi
riteshmodi / LettuceRedisClientConnectionPooling.java
Created August 24, 2014 05:11
Lettuce Redis Connection pooling through Spring RedisTemplate
import org.apache.commons.pool.impl.GenericObjectPool.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.lettuce.DefaultLettucePool;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
@Component
public class LettuceRedisClientConnectionPooling {
@EDCHRONO-GIT
EDCHRONO-GIT / InputfieldDemoController
Last active March 16, 2016 02:02
VisualForce: Passing Values from Javascript to Controller
public class InputfieldDemoController {
//Variable under test
public String valuefromJS {get; set;}
public pagereference someMethod(){
System.debug(valuefromJS);
return null;
package com.appspot.dangt85.controllers;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@jasimpson
jasimpson / python-parfor.py
Last active March 12, 2020 23:57
Example code to demonstrate parallel for (parfor) loop implementation using joblib
# Example code to demonstrate parallel for loop implementation using joblib
from joblib import Parallel, delayed
import multiprocessing
# Vars
my_list = range(10)
squares = []
# Function to parallelize
def find_square(i):
@jbeezley
jbeezley / ls.py
Created April 8, 2015 18:04
Recursively list files in s3
#!/usr/bin/env python
import sys
import json
from boto.s3.connection import S3Connection
from boto.s3.prefix import Prefix
from boto.s3.key import Key
bucketname = sys.argv[1]
delimiter = '/'
/* SF OAuth request, redirect to SF login */
app.get('/oauth/auth', function(req, res) {
res.redirect(oauth2.getAuthorizationUrl({scope: 'api id web'}));
});
/* OAuth callback from SF, pass received auth code and get access token */
app.get('/oauth/callback', function(req, res) {
var conn = new jsforce.Connection({oauth2: oauth2});
var code = req.query.code;
conn.authorize(code, function(err, userInfo) {
@bonzanini
bonzanini / config.py
Last active May 20, 2025 02:55
Twitter Stream Downloader
consumer_key = 'your-consumer-key'
consumer_secret = 'your-consumer-secret'
access_token = 'your-access-token'
access_secret = 'your-access-secret'
@doppiomacchiatto
doppiomacchiatto / .bash_profile
Created April 9, 2016 18:01 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management