Skip to content

Instantly share code, notes, and snippets.

def fuzzyfinder(p, l):
return map(lambda t: t[0], sorted(filter(lambda t: all(map(lambda x: x != -1, t[1])), map(lambda s: (s,map(s.find, p)), l)), key=lambda t: t[1]))
@lukehedger
lukehedger / ffmpeg-compress-mp4
Last active May 2, 2025 14:50
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@gwintrob
gwintrob / gist:6abc086b2425f3a8d5c8
Created December 4, 2014 20:03
Delete redis keys with unmatched single quotes
redis-cli KEYS 'icc*' | xargs -d '\n' redis-cli DEL
@kaikuchn
kaikuchn / benchmark.rb
Last active December 7, 2015 08:47
bulk insert benchmark
#!/usr/bin/env ruby
require 'benchmark'
require File.expand_path('../config/environment', __FILE__)
begin
@list = (0..10_000).map{|i| {word: "word_#{i}", word_translation: "translation_#{i}"}}
@vocabulary_1 = Vocabulary.create(user_id: User.first.id, title: "Vocabulary #1")
@vocabulary_2 = Vocabulary.create(user_id: User.first.id, title: "Vocabulary #2")
@vocabulary_3 = Vocabulary.create(user_id: User.first.id, title: "Vocabulary #3")
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 4, 2025 21:20
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@staltz
staltz / introrx.md
Last active May 6, 2025 07:45
The introduction to Reactive Programming you've been missing
@hlawrenz
hlawrenz / flower command line
Last active February 5, 2023 19:00
Serve celery flower behind Django authentication.
celery flower --address=127.0.0.1 --url_prefix=flower --broker=<broker url>
@tonycoco
tonycoco / controller_spec.rb
Last active May 25, 2023 06:04
The Greatest Hits of Rspec Testing: Volume 1
require "spec_helper"
describe ExampleController do
context "GET #index" do
let(:resources) { FactoryGirl.create_list(:resource) }
before do
get :index
end
@jdkanani
jdkanani / notepad.html
Last active June 16, 2024 13:44 — forked from jakeonrails/Ruby Notepad Bookmarklet
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@leommoore
leommoore / nginx_basics.md
Last active February 20, 2025 07:27
Nginx Basics

#Nginx Basics for Ubuntu

Please see http://wiki.nginx.org/Main for more information. See http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/ for a tutorial on how to install Nginx.

##Installation To install, you can install the version which is in the standard Ubuntu repositories but it is normally quite old and will not have the latest security patches. The best way is to update the repositories first:

apt-get update
apt-get install python-software-properties

apt-get upgrade