Skip to content

Instantly share code, notes, and snippets.

@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")
@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
@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
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]))
@imbolc
imbolc / aiohttp_rq.py
Created October 28, 2015 09:03
Testing of aiohttp + rq performance
'''
I started one server:
$ python aiohttp_rq.py server
And three workers in different terminals:
$ python aiohttp_rq.py worker
And I got next results with ab:
@nepsilon
nepsilon / how-to-bash-batch-rename.md
Last active July 7, 2016 06:15
How to batch rename files with bash? — First published in fullweb.io issue #36

How to batch rename files with bash?

Let’s say we have these files:

ls 
to_be_renamed_1.txt 
to_be_renamed_2.txt 
to_be_renamed_3.txt 
@nepsilon
nepsilon / 3-postgres-tips.md
Last active February 19, 2017 13:19
3 tips for a better PostgreSQL usage — First published in fullweb.io issue #38

3 tips for a better PostgreSQL usage

We’ll see how to write queries in your editor, format output based on content and how to get info on everything.

1. Use your editor to write queries:

Tell the terminal what editory to use with from your bash shell export EDITOR=subl, then in psql type:

psql> \e
@maxpoletaev
maxpoletaev / youtube_migrate.py
Last active July 31, 2021 16:52
Transfer YouTube subscriptions to another account
"""
Automatic migration of subscriptions to another
YouTube account with Python and Selenium.
Tested with:
- selenium 3.0
- firefox 49.0
- python 3.5
1. Install selenium from pypi:
@nepsilon
nepsilon / csvkit.md
Last active July 7, 2016 05:34
Need to make sense of large CSV files? — First published on fullweb.io issue #44

Need to make sense of large CSV files?

Often you are handed-out big CSV files and need to sort, filter, update some cells or other tedious work. You tried sed, jq, and maybe the mighty awk.

But at the end of the day: You’re using the wrong tool for the job.

Here come csvkit’s csvsql, a small Python script to parse your CSV files and create the corresponding database. You now have the best tool, SQL, to answer your data questions:

@nepsilon
nepsilon / one-line-browser-notepad.md
Created September 27, 2016 05:25
One-line browser notepad 📝 — First published in fullweb.io issue #67

One-line browser notepad 📝

Sometimes you just need to quickly take some notes.

A trick is to use the data: scheme with data:text/html to show just a piece of HTML in your browser. Then using the mighty contentEditable to make the whole thing editable.

To copy/paste into your browser address bar:

data:text/html,<html contenteditable>