Skip to content

Instantly share code, notes, and snippets.

View mushfiq's full-sized avatar

Mushfiq mushfiq

View GitHub Profile
@coudron
coudron / view.py
Last active May 20, 2016 20:58
Python and Objective-C code that enables an iOS app to upload images directly to an S3 bucket using a secure authorization header generated by a python server Code is a Fork from Stackoverflow answer: http://stackoverflow.com/questions/4481311/architectural-and-design-question-about-uploading-photos-from-iphone-app-and-s3 Let me know what you th…
- (void)uploadImage:(UIImage *)image
{
//Set up the upload request from our server
NSURL *url = [NSURL URLWithString:@"http://<your-server-url-here>/"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
// Pull out any required information out of the response
NSString *serverDate = [JSON valueForKeyPath:@"date_string"];
@ChatchaiJ
ChatchaiJ / install-changetrack
Created December 8, 2015 07:00
Install changetrack on debian/ubuntu host
#!/bin/bash
# --------------------------------------------------------------------- #
# install-changetrack - Install changetrack on debian/ubuntu host. #
# #
# version 0.1 - cj (2010-08-24) init. #
# --------------------------------------------------------------------- #
ADMIN="sysadmin@localhost"
CONF="/etc/changetrack.conf"
@dspezia
dspezia / gist:1771342
Created February 8, 2012 17:19
Example of Redis zset + key iteration + pipelining in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ----------------------------------------------------
import redis, random
POOL = redis.ConnectionPool(host='localhost', port=6379, db=0)
NUSERS = 10000
NTAGS = 500
@jpadilla
jpadilla / exceptions.py
Created January 15, 2014 00:41
Custom exception handler for Django Rest Framework that adds the `status_code` to the response and renames the `detail` key to `error`.
from rest_framework.views import exception_handler
def custom_exception_handler(exc):
"""
Custom exception handler for Django Rest Framework that adds
the `status_code` to the response and renames the `detail` key to `error`.
"""
response = exception_handler(exc)
@devinrader
devinrader / gist:ba796aa318174958c14c
Last active November 22, 2018 18:05
Receive and Set Session Values using Flask and KVSession
from flask import Flask, request, make_response, session
from flaskext.kvsession import KVSessionExtension
from datetime import datetime, timedelta
from twilio import twiml
import json
import redis
from simplekv.memory.redisstore import RedisStore
SECRET_KEY = 'a secret key'
@marcelcaraciolo
marcelcaraciolo / tf_idf_final.py
Created January 13, 2012 03:38
tf-idf example
#-*- coding: utf-8 -*-
import re
import nltk
from nltk.tokenize import RegexpTokenizer
from nltk import bigrams, trigrams
import math
stopwords = nltk.corpus.stopwords.words('portuguese')
@devinrader
devinrader / gist:d50234733b8e059b98b8
Last active August 15, 2019 03:14
Receiving and Setting Cookies using Flask
from flask import Flask, request, make_response
from datetime import datetime, timedelta
from twilio import twiml
app = Flask(__name__)
@app.route("/sms")
def sms():
#get the cookie value, or default to zero
@carlossg
carlossg / Dockerfile
Created December 17, 2014 19:19
ansible maven
FROM ansible/centos7-ansible:stable
# or, for example, FROM ansible/ubuntu14.04-ansible:stable
RUN yum install -y tar
RUN ansible-galaxy install geerlingguy.java
RUN ansible-galaxy install https://github.com/silpion/ansible-maven.git
# Add playbooks to the Docker image
COPY site.yml /
@meznak
meznak / infb.py
Created December 22, 2011 21:36 — forked from ruel/infb.py
A script to scrape information from your facebook friends.
#!/usr/bin/python
'''
InFB - Information Facebook
Usage: infb.py user@domain.tld password
infb.py
http://ruel.me
@anhpt379
anhpt379 / tf_idf_final.py
Created January 13, 2012 07:51 — forked from marcelcaraciolo/tf_idf_final.py
tf-idf example
#-*- coding: utf-8 -*-
import re
import nltk
from nltk.tokenize import RegexpTokenizer
from nltk import bigrams, trigrams
import math
stopwords = nltk.corpus.stopwords.words('portuguese')