Skip to content

Instantly share code, notes, and snippets.

View CalebM1987's full-sized avatar

Caleb Mackey CalebM1987

View GitHub Profile
@aisipos
aisipos / jsonp-in-flask.py
Created July 20, 2011 01:20 — forked from farazdagi/jsonp-in-flask.py
JSONP in Flask
import json
from functools import wraps
from flask import redirect, request, current_app
def support_jsonp(f):
"""Wraps JSONified output for JSONP"""
@wraps(f)
def decorated_function(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@jasonrudolph
jasonrudolph / gist:6057563
Last active December 15, 2023 14:52
GitHub Search API: Get the number of stars for a repository

James Sugrue [asked][1], "@GitHubAPI is there a way to find the number of stars for a given repository?"

Example

$ curl -ni "https://api.github.com/search/repositories?q=more+useful+keyboard" -H 'Accept: application/vnd.github.preview'
{
@ca0v
ca0v / async.js
Created November 13, 2013 15:14
async plugin specifically for google maps. example: require(["plugins/async!http://maps.google.com/maps/api/js?v=3&sensor=false"], function () {// can use google.maps now});
/**
* Dojo AMD Google Maps Loader Plugin
*/
define([
"dojo/_base/kernel",
"dojo/topic"
], function (kernel, topic) {
var w = kernel.global;
var cb ="_googleApiLoadCallback";
@davidnormo
davidnormo / main.js
Last active May 17, 2022 16:56
jsPDF as email attachment
var pdf = new jsPDF();
pdf.text(0, 0, 'Hello World!');
var pdfBase64 = pdf.output('datauristring');
window.plugin.email.open({
to: ['to@email.com'],
subject: 'New PDF!',
body: 'Hi there, here is that new PDF you wanted!',
isHTML: false,
attachments: [pdfBase64]
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@sphvn
sphvn / traverse.js
Last active October 26, 2023 21:49
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
var traverse = function(o, fn) {
for (var i in o) {
fn.apply(this,[i,o[i]]);
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
}
}
}
// usage
@mick-t
mick-t / gist:85fc40d1acaf5e98cad9
Created June 18, 2015 20:19
Python-LDAP: find the groups a user is a member of.
LDAP_SERVER = "ldaps://my-ldap-server.com/"
LDAP_BASE = "dc=my-ldap-server,dc=com"
def users_ldap_groups(uid):
""" Returns a list of the groups that the uid is a member of.
Returns False if it can't find the uid or throws an exception.
It's up to the caller to ensure that the UID they're using exists!
"""
logger.debug("uid: ", uid)
@noelvo
noelvo / download-multiple-files.js
Created December 6, 2015 23:22
Download multiple files then compress to one zip file using JSZip & JSZip-utils
var zip = new JSZip();
var count = 0;
var zipFilename = "zipFilename.zip";
var urls = [
'http://image-url-1',
'http://image-url-2',
'http://image-url-3'
];
urls.forEach(function(url){
@joongh
joongh / rsaencdec.py
Created January 13, 2016 08:44
Encryption, Decryption using RSA (PKCS1_v1_5) in Python
#!/usr/bin/env python
#-*- coding: utf-8 -*-
from Crypto.Cipher import PKCS1_v1_5
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA
from Crypto import Random
import base64
import StringIO
# passphrase, random string => private key, public key pair