Skip to content

Instantly share code, notes, and snippets.

View chris-vecchio's full-sized avatar

Chris Vecchio chris-vecchio

View GitHub Profile
@cowboy
cowboy / stringify.js
Created September 19, 2012 13:45
JavaScript: like JSON.stringify but handles functions, good for creating arbitrary .js objects?
var stringify = function(obj, prop) {
var placeholder = '____PLACEHOLDER____';
var fns = [];
var json = JSON.stringify(obj, function(key, value) {
if (typeof value === 'function') {
fns.push(value);
return placeholder;
}
return value;
}, 2);
@ColinDuquesnoy
ColinDuquesnoy / html_logger.py
Last active June 19, 2024 17:23
HTML logger for python (inspired by the Horde3D logger)
"""
HTML logger inspired by the Horde3D logger.
Usage:
- call setup and specify the filename, title, version and level
- call dbg, info, warn or err to log messages.
"""
import logging
import time
@mrkline
mrkline / c_sharp_for_python.md
Last active July 21, 2024 08:51
An intro to C# for a Python developer. Made for one of my coworkers.

C# For Python Programmers

Syntax and core concepts

Basic Syntax

  • Single-line comments are started with //. Multi-line comments are started with /* and ended with */.

  • C# uses braces ({ and }) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,

Handlebars is a semantic web template system, started by Yehuda Katz in 2010.
Handlebars.js is a superset of Mustache, and can render Mustache templates in addition to Handlebars templates.
More: http://handlebarsjs.com/
1. Expressions.
1.1 Basic usage.
// Highcharts CheatSheet Part 1.
// Create interactive charts easily for your web projects.
// Download: http://www.highcharts.com/download
// More: http://api.highcharts.com/highcharts
// 1. Installation.
// Highcharts requires two files to run, highcharts.js and either jQuery, MooTools or Prototype or the Highcharts Standalone Framework which are used for some common JavaScript tasks.
// <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
// <script src="https://code.highcharts.com/highcharts.js"></script>
@juancarlospaco
juancarlospaco / qmainwindow.py
Last active March 1, 2022 02:38
Custom QMainWindow with cool features for Python3 Qt5.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Custom QMainWindow Widget."""
import os
import sys
from random import randint
@sethlopezme
sethlopezme / full-match.js
Last active February 13, 2024 07:35
Regex for matching any hex, rgb(a), or hsl(a) value. Assumes that you've lowercased the string and removed spaces.
/^(#?([a-f\d]{3,4}|[a-f\d]{6}|[a-f\d]{8})|rgb\((0|255|25[0-4]|2[0-4]\d|1\d\d|0?\d?\d),(0|255|25[0-4]|2[0-4]\d|1\d\d|0?\d?\d),(0|255|25[0-4]|2[0-4]\d|1\d\d|0?\d?\d)\)|rgba\((0|255|25[0-4]|2[0-4]\d|1\d\d|0?\d?\d),(0|255|25[0-4]|2[0-4]\d|1\d\d|0?\d?\d),(0|255|25[0-4]|2[0-4]\d|1\d\d|0?\d?\d),(0|0?\.\d|1(\.0)?)\)|hsl\((0|360|35\d|3[0-4]\d|[12]\d\d|0?\d?\d),(0|100|\d{1,2})%,(0|100|\d{1,2})%\)|hsla\((0|360|35\d|3[0-4]\d|[12]\d\d|0?\d?\d),(0|100|\d{1,2})%,(0|100|\d{1,2})%,(0?\.\d|1(\.0)?)\))$/
@stefanthoss
stefanthoss / cik_dict.py
Last active December 2, 2019 16:01 — forked from dougvk/cik_dict.py
(stock ticker -> CIK) dictionary using SEC EDGAR using stdout
import re
import requests
DEFAULT_TICKERS = ["BBRY", "VOD", "T", "S"]
URL = "http://www.sec.gov/cgi-bin/browse-edgar?CIK={}&Find=Search&owner=exclude&action=getcompany"
CIK_RE = re.compile(r".*CIK=(\d{10}).*")
cik_dict = {}
for ticker in DEFAULT_TICKERS:
results = CIK_RE.findall(requests.get(URL.format(ticker)).content.decode("ascii"))
@bbengfort
bbengfort / sentiment.py
Last active December 27, 2022 05:17
An end-to-end demonstration of a Scikit-Learn SVM classifier trained on the positive and negative movie reviews corpus in NLTK.
import os
import time
import string
import pickle
from operator import itemgetter
from nltk.corpus import stopwords as sw
from nltk.corpus import wordnet as wn
from nltk import wordpunct_tokenize
@brendancol
brendancol / translate_alaska_hawaii.py
Last active April 23, 2021 17:38
Translating Alaska and Hawaii (Bokeh + Shapely)
import json
from bokeh.io import output_file
from bokeh.plotting import figure, show
from bokeh.models import GeoJSONDataSource
from shapely import affinity
from shapely.geometry import mapping, shape
def get_geojson():