Skip to content

Instantly share code, notes, and snippets.

@hubgit
hubgit / GoogleReaderClient.php
Last active December 18, 2015 09:48
PHP Google Reader Client
<?php
// Create an application at https://code.google.com/apis/console/
// Generate client id + secret: API Access > Generate Client Id > Installed application
class GoogleReaderClient {
/** @var cURL */
public $curl;
private $config = array();
@jtojnar
jtojnar / linter.md
Last active December 18, 2015 22:08

This is no longer maintained. Please check my fork.

I wanted SublimeLinter to automatically validate XML against XSD, but this AFAIK isn’t possible so I made a wrapper for xmllint utility to find XSD file in source code and pass it as argument to xmllint. Because XSD paths can be relative I had to change xml.py to use INPUT_METHOD_FILE (@ instead od -) so I could detect file path. Currently the wrapper is quite stupid but it can be changed when I come across something that doesn’t work.

Tested with SublimeLinter3, libxml version 20902 and Python 3.4.3

Save xmllintschema to ~/bin directory (or another directory on path) and set executable bit (chmod +x xmllintschema).

  1. Click PreferencesBrowse Packages → SublimeLinter-xmllint, open linter.py
@max-mapper
max-mapper / index.js
Last active May 9, 2021 02:20
fast loading of a large dataset into leveldb
// data comes from here http://stat-computing.org/dataexpo/2009/the-data.html
// download 1994.csv.bz2 and unpack by running: cat 1994.csv.bz2 | bzip2 -d > 1994.csv
// 1994.csv should be ~5.2 million lines and 500MB
// importing all rows into leveldb took ~50 seconds on my machine
// there are two main techniques at work here:
// 1: never create JS objects, leave the data as binary the entire time (binary-split does this)
// 2: group lines into 16 MB batches, to take advantage of leveldbs batch API (byte-stream does this)
var level = require('level')
<?php
/**
* Callable typehints are only supported in php >= 5.4.
*
* For PHP 5.3, remove callable typehint, use is_callable($callback) instead.
*/
/**
* Returns true if the given predicate is true for all elements.
*/
@ldodds
ldodds / senior-staff-organagram.json
Last active November 17, 2019 07:50
Draft Schema for UK Govt Senior Staff Organagram CSV
{
"title": "UK Government Organagram",
"description": "Draft schema for validating CSV files collected as part of publishing UK Government organagrams",
"fields": [
{
"name": "Post Unique Reference",
"title": "Post Unique Reference",
"description": "Unique id for a post",
"constraints": {
"required": true,
@ldodds
ldodds / land-registry-price-paid.json
Last active April 20, 2022 01:18
Land Registry Monthly Price Paid Schema (CSV, new version)
{
"title": "Land Registry Monthly Price Paid Data",
"description": "Schema for the land registry monthly price-paid data",
"fields": [
{
"name": "ID",
"description": "Unique transaction code",
"constraints": {
"required": true,
"minLength": 38,
@mcasperson
mcasperson / gist:11315910
Last active December 3, 2020 07:49
Pandoc Emscripten
Add this to Ghc-Options in pandoc.cabal
-fllvm -keep-llvm-files -fforce-recomp
./emcc <all *.ll files> -o pandoc.js
emcc ./src/Text/Pandoc.ll ./src/Text/Pandoc/Compat/TagSoupEntity.ll ./src/Text/Pandoc/Compat/Monoid.ll ./src/Text/Pandoc/XML.ll ./src/Text/Pandoc/Writers/ICML.ll ./src/Text/Pandoc/Writers/FB2.ll ./src/Text/Pandoc/Writers/Man.ll ./src/Text/Pandoc/Writers/EPUB.ll ./src/Text/Pandoc/Writers/RST.ll ./src/Text/Pandoc/Writers/Docbook.ll ./src/Text/Pandoc/Writers/Org.ll ./src/Text/Pandoc/Writers/Markdown.ll ./src/Text/Pandoc/Writers/HTML.ll ./src/Text/Pandoc/Writers/ConTeXt.ll ./src/Text/Pandoc/Writers/Docx.ll ./src/Text/Pandoc/Writers/Texinfo.ll ./src/Text/Pandoc/Writers/MediaWiki.ll ./src/Text/Pandoc/Writers/Native.ll ./src/Text/Pandoc/Writers/Shared.ll ./src/Text/Pandoc/Writers/OpenDocument.ll ./src/Text/Pandoc/Writers/ODT.ll ./src/Text/Pandoc/Writers/Custom.ll ./src/Text/Pandoc/Writers/OPML.ll ./src/Text/Pandoc/Writers/RTF.ll ./src/Text/Pandoc/Writers/AsciiDoc.ll ./src/Text/Pandoc/Writers/LaTeX.l
@igrigorik
igrigorik / json-bq-schema-generator.rb
Last active November 3, 2022 17:34
BigQuery JSON schema generator
require 'open-uri'
require 'zlib'
require 'yajl'
# References
# - https://developers.google.com/bigquery/preparing-data-for-bigquery#dataformats
# - https://developers.google.com/bigquery/docs/data#nested
#
def type(t)
@Globegitter
Globegitter / es.sh
Last active November 18, 2020 12:52
Easy install for elasticsearch on Ubuntu 14.04
cd ~
##If you want to install OpenJDK
#sudo apt-get update
#sudo apt-get install openjdk-8-jre-headless -y
###Or if you want to install Oracle JDK, which seems to have slightly better performance
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
@edsu
edsu / gist:7356efa67342515f9026
Last active August 29, 2015 14:05
top 50 URLs in first 50k #ferguson tweets I was able to start collecting from the evening of August 10th.
1191 http://ago.mo.gov/VehicleStops/2013/reports/161.pdf
1056 https://vine.co/v/MVY6ZMdIlOr
954 https://www.youtube.com/watch?v=eOSRQ-c1XW0
912 http://new.livestream.com/ktvi/live
541 https://vine.co/v/MVYHJUgKVa9
476 http://instagram.com/p/ri0ZLhTC9C/
363 https://vine.co/v/MVVT5BehUpM
345 http://www.broadcastify.com/listen/feed/2418/web
324 http://bit.ly/1ou3Hwz
321 https://vine.co/v/MVQje76ul0d