Skip to content

Instantly share code, notes, and snippets.

@c0ldlimit
c0ldlimit / git_newrepo
Created November 16, 2012 17:14
Git: Push a new or existing repo to Github
# Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/c0ldlimit/vimcolors.git
git push -u origin master
# Push an existing repository from the command line
@c0ldlimit
c0ldlimit / gist:4961066
Last active July 27, 2023 16:52
Setting up #Ubuntu #ubuntu
sudo apt update
sudo apt upgrade
# https://www.digitalocean.com/community/tutorials/how-to-create-a-new-sudo-enabled-user-on-ubuntu-22-04-quickstart
# https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-linux/
# https://docs.conda.io/en/main/miniconda.html
# Setting up Ubuntu
# check locale
@c0ldlimit
c0ldlimit / gist:3f4d20b978f5130c6b10
Created September 2, 2014 03:35
#python sqlite job queue
# http://flask.pocoo.org/snippets/88/
import os, sqlite3
from cPickle import loads, dumps
from time import sleep
try:
from thread import get_ident
except ImportError:
from dummy_thread import get_ident
@c0ldlimit
c0ldlimit / gist:4287824
Last active September 5, 2022 07:47
Converting None to NaN in numpy when casting a list to numpy arrays #numpy #c0ldlimit #python
import numpy as np
x = array([3,4,None,55])
y = np.array(x,dtype=float)
# OR
y = np.array(x)
z = y.astype(float)
@c0ldlimit
c0ldlimit / gist:4091273
Last active November 6, 2020 22:04
Python: How to use *args and **kwargs #python #args #kwargs #c0ldlimit
# This example passes one formal (positional) argument, and two more variable length arguments.
def test_var_args(farg, *args):
print "formal arg:", farg
for arg in args:
print "another arg:", arg
test_var_args(1, "two", 3)
# Here is an example of how to use the keyworded form. Again, one formal argument and two keyworded variable arguments are passed.
def test_var_kwargs(farg, **kwargs):
@c0ldlimit
c0ldlimit / gist:5164171
Created March 14, 2013 19:00
#python #flask #pandas Using flask to return a csv response from a dataframe
import StringIO
from flask import Flask, Response
@app.route('/some_dataframe.csv')
def output_dataframe_csv():
output = StringIO.StringIO()
some_dataframe.to_csv(output)
@c0ldlimit
c0ldlimit / gist:634ea60bc8d79ac6340a
Created January 2, 2015 18:07
#bloomberg refresh formulas
' http://stackoverflow.com/questions/12856979/how-to-refresh-load-rtd-bloomberg-function-bdh-in-excel-in-vba
Application.run "RefreshAllWorkbooks"
Application.run "RefreshAllStaticData"
@c0ldlimit
c0ldlimit / index.html
Created September 4, 2014 19:10
#python #tornado pass arguments from tornado to js and not just html
# http://stackoverflow.com/questions/19112296/how-to-pass-arguments-from-tornado-to-a-js-file-but-not-html
$ tree
.
├── static
│ └── scripts
│ └── test.js
├── templates
│ └── index.html
└── test.py
import os
import random
from scrapy.conf import settings
class RandomUserAgentMiddleware(object):
def process_request(self, request, spider):
ua = random.choice(settings.get('USER_AGENT_LIST'))
if ua:
request.headers.setdefault('User-Agent', ua)
class ProxyMiddleware(object):
@c0ldlimit
c0ldlimit / gist:5953014
Created July 8, 2013 22:25
#python multiple #tor workers
#!/usr/bin/python
import httplib
import socks
import urllib2
from Queue import Queue
from threading import Thread, Condition, Lock
from threading import active_count as threading_active_count
import time