Skip to content

Instantly share code, notes, and snippets.

View amitu's full-sized avatar
😀
Building fastn.com

Amit Upadhyay amitu

😀
Building fastn.com
View GitHub Profile
#!/usr/bin/env ruby
require 'base64'
require 'open-uri'
# file or url
def get_css(src)
if src.start_with? 'http'
src = src.gsub('|', '%7C')
STDERR.puts "# GET #{src}"
# simulate modern browser to get woff
@thomasballinger
thomasballinger / subprocess.py
Created December 15, 2013 23:26
Using a pseudo-terminal to interact with interactive Python in a subprocess
from subprocess import Popen, PIPE
import pty
import os
from select import select
import sys
import tty
master, slave = pty.openpty()
p = Popen(['python'], stdin=slave, stdout=PIPE, stderr=PIPE)
pin = os.fdopen(master, 'w')
package httptimeout
import (
"net/http"
"time"
"fmt"
)
type TimeoutTransport struct {
http.Transport
@chrisclark
chrisclark / pypi-release-checklist.md
Last active April 3, 2018 13:17 — forked from audreyfeldroy/pypi-release-checklist.md
SQL Explorer Release Checklist
  • Update HISTORY
  • Update README and check formatting with http://rst.ninjs.org/
  • Make sure any new files are included in MANIFEST.in
  • Update version number in explorer/__init__.py
  • Update any package dependencies in setup.py
  • Commit the changes:
git add .
git commit -m "Release 1.0.0"
@haasn
haasn / about:config.md
Last active April 2, 2024 18:46
Firefox bullshit removal via about:config

Firefox bullshit removal

Updated: Just use qutebrowser (and disable javascript). The web is done for.

@androidfred
androidfred / haskell_stack_and_intellij_idea_ide_setup_tutorial_how_to_get_started.md
Last active February 4, 2024 20:58
Haskell, Stack and Intellij IDEA IDE setup tutorial how to get started

Haskell, Stack and Intellij IDEA IDE setup tutorial how to get started

Upon completion you will have a sane, productive Haskell environment adhering to best practices.

Basics

  • Haskell is a programming language.
  • Stack is tool for Haskell projects. (similar tools for other languages include Maven, Gradle, npm, RubyGems etc)
  • Intellij IDEA IDE is a popular IDE.

Install required libraries

sudo apt-get install libtinfo-dev libghc-zlib-dev libghc-zlib-bindings-dev

@chalmagean
chalmagean / onSelect.elm
Last active December 22, 2016 06:21
Elm onSelect decoder
-- Assuming we have a list of items in the model (type alias Model = { items : List Item }
-- where Item is a record like { id : Int, name : String }
-- this goes in the view and generates an html dropdown
select
[ onSelect ValueSelectedMsg ]
(List.map (\item -> option [ value (toString item.id) ] [ text item.name ]) model.items)
targetSelectedIndex : Json.Decoder Int
@SethCalkins
SethCalkins / LittleSnitch_Block_List.md
Last active January 5, 2023 05:17
Little Snitch Script to block Ad Servers

Here is a script to take the hosts from From http://pgl.yoyo.org/adservers/ and convert them to rules for Little Snitch.

It has options to grab the entire list or grab new entries past a certain date.

Just grab the output and copy/paste into Little Snitch.

The script is written to block access to any process, any port. You can also delete those lines and it will only block Mail. Or use the options to enter any process, port or protocol you want to block.

A Beginner's Hip Hop Playlist

Edit: After some constructive feedback on hacker news, I think that it's worth mentioning that this playlist is very skewed towards recent material, although I've included some essentials from the past.

I think that hip hop is one of the most, if not the most, misunderstood genres of music. In this playlist, rather than focusing on one artist or one type of hip hop, I tried to give examples of a bunch of different artists with songs ranging from the early 90's all the way up until 2017. The songs are in no particular order and the sounds cover a very broad spectrum. Some of them are pretty damn explicit, so I wouldn't necessarily throw this playlist on if there are kids around. I provided the lyrics to each song, the sub-genre that I'd put the artist in (very rough), and a brief description. This playlist is not by any means meant to be comprehensive and in many cases doesn't necessarily represent the artist's "best" song, but instead aims at exposing you to some of my fa

#!/usr/bin/python
# to try this you'll need to edit in the name of your ruby binary and install bcc-tools
# bcc installation instructions are at https://github.com/iovisor/bcc/blob/master/INSTALL.md
from __future__ import print_function
from bcc import BPF
from time import sleep
import os
# load BPF program