Skip to content

Instantly share code, notes, and snippets.

View antikytheraton's full-sized avatar
💻
configuring nvim

Aaron Arredondo antikytheraton

💻
configuring nvim
View GitHub Profile
@miku
miku / 4956984-1.py
Created February 10, 2011 13:16
How do you split a csv file into evenly sized chunks in Python?
#!/usr/bin/env python
# import csv
# reader = csv.reader(open('4956984.csv', 'rb'))
def gen_chunks(reader, chunksize=100):
"""
Chunk generator. Take a CSV `reader` and yield
`chunksize` sized slices.
"""
@chm0815
chm0815 / fblogin.py
Created August 1, 2012 21:28
Facebook Login Script
import sys, urllib, urllib2, cookielib
class FacebookLogin(object):
def __init__(self,user,passw):
self.user=user
self.passw=passw
self.browser = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
self.browser.addheaders=[('User-agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0')]
urllib2.install_opener(self.browser)
@econchick
econchick / gist:4666413
Last active December 22, 2023 13:32
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
import math
from text.blob import TextBlob as tb
def tf(word, blob):
return blob.words.count(word) / len(blob.words)
def n_containing(word, bloblist):
return sum(1 for blob in bloblist if word in blob)
def idf(word, bloblist):
@samoturk
samoturk / Dockerfile-rdkit
Last active August 23, 2022 01:29
Docker file that installs docker container with rdkit, ipython notebook and matplotlib
# Docker file that installs docker container with rdkit, ipython notebook and matplotlib
#
# rename this file to "Dockerfile"
# build with: "sudo docker build -t rdkit ."
# run with: "sudo docker run -p 127.0.0.1:8889:8888 rdkit "
# NOTE that here port 8888 gets mapped to 8889.
# point your browser to http://127.0.0.1:8889/
FROM saltstack/ubuntu-13.10
# Add universe repository
@cdrx
cdrx / gist:6952891
Created October 12, 2013 17:57
Django user registration with a custom user model via a Django REST Framework request
from django.contrib.auth import get_user_model
from rest_framework import status, serializers
from rest_framework.decorators import api_view
from rest_framework.response import Response
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = get_user_model()
@shawnrice
shawnrice / skeleton-daemon.sh
Created April 19, 2014 07:22
A template to write a quick daemon as a bash script
#!/bin/sh
# This is a skeleton of a bash daemon. To use for yourself, just set the
# daemonName variable and then enter in the commands to run in the doCommands
# function. Modify the variables just below to fit your preference.
daemonName="DAEMON-NAME"
pidDir="."
pidFile="$pidDir/$daemonName.pid"
@marcellodesales
marcellodesales / formatted.sh
Last active November 14, 2023 19:22
One-liner REST server using netcat - nc
rm -f out
mkfifo out
trap "rm -f out" EXIT
while true
do
cat out | nc -w1 -l 1500 > >( # parse the netcat output, to build the answer redirected to the pipe "out".
export REQUEST=
while read line
do
line=$(echo "$line" | tr -d '[\r\n]')
@richard512
richard512 / month-name-number-conversion.js
Last active November 21, 2022 03:19
JavaScript: Month name to Number and Month number to month name
var months = [
'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September',
'October', 'November', 'December'
];
function monthNumToName(monthnum) {
return months[monthnum - 1] || '';
}
function monthNameToNum(monthname) {
@UndergroundLabs
UndergroundLabs / gist:fad38205068ffb904685
Created October 3, 2015 19:46
Facebook Python Login Script
#!/home/drspock/scripts/FBInvite/bin/python
import argparse
import requests
import pyquery
def login(session, email, password):
'''
Attempt to login to Facebook. Returns user ID, xs token and