Skip to content

Instantly share code, notes, and snippets.

View mervick's full-sized avatar

Andrey Izman mervick

View GitHub Profile
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
urlencode() {
# urlencode <string>
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c"
esac
@mervick
mervick / tmp.c
Created October 6, 2015 12:03 — forked from hadess/tmp.c
Hack to control the keyboard backlight level on a Thinkpad Lenovo X1 Carbon Touch
/* gcc -o tmp `pkg-config --libs --cflags glib-2.0` tmp.c
*
* # modprobe ec_sys
*
* # watch -n 0.1 hexdump -C /sys/kernel/debug/ec/ec0/io
*
* 00000000 a7 05 a0 e2 00 86 05 00 00 00 47 00 00 03 00 10 |..........G.....|
* 00000000 a7 05 a0 e2 00 86 05 00 00 00 47 00 00 43 00 10 |..........G..C..|
* 00000000 a7 05 a0 e2 00 86 05 00 00 00 47 00 00 83 00 10 |..........G.....|
@mervick
mervick / README.md
Created October 16, 2015 01:56 — forked from evandrix/README.md
Headless web browsers

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.
@mervick
mervick / Readme.txt
Created November 13, 2015 13:14 — forked from endolith/Readme.txt
Gnome to Wine color scraper
This is a Python script to extract GNOME/GTK's color scheme and apply it to Wine, so that the themes (approximately) match.
Instructions:
1. Set your Gnome theme as you would like it
2. Run with a command like "python wine_colors_from_gtk.py"
3. Restart any apps running in Wine. They should match the Gnome theme colors now.
Better description with screenshots here: http://www.endolith.com/wordpress/2008/08/03/wine-colors/
This is also stored on https://code.launchpad.net/~endolith/+junk/wine-color-scraper
@mervick
mervick / toggle-css-script-on-off.js
Created November 15, 2015 20:56 — forked from AllThingsSmitty/toggle-css-script-on-off.js
Disable/enable a stylesheet or script
// Use the Boolean `disabled` attribute
myCSS.disabled = true;
myJS.disabled = true;
// Create a stylesheet toggle button:
var stylesheet = document.getElementById('boot'),
btn = document.querySelector('.btn');
btn.addEventListener('click', function () {
stylesheet.disabled = (stylesheet.disabled === false) ? true : false;
@mervick
mervick / nginx.conf
Created November 22, 2015 21:17 — forked from jrom/nginx.conf
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@mervick
mervick / npm-upgrade-bleeding.sh
Last active December 3, 2015 10:18 — forked from othiym23/npm-upgrade-bleeding.sh
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
@mervick
mervick / README.md
Created December 5, 2015 01:19 — forked from bergie/README.md
Backbone.js Collection View example

This is an example of using a Collection view with Backbone.

@mervick
mervick / Chrome custom scrollbar.css
Created March 23, 2016 04:12 — forked from oumu/Chrome custom scrollbar.css
CSS : Chrome custom scrollbar
/*http://support.google.com/chrome/?hl=en*/
::-webkit-scrollbar {
height: 16px !important;
overflow: visible !important;
width: 16px !important;
}
::-webkit-scrollbar-thumb {
background: -webkit-linear-gradient(left, rgba(198,198,198,1) 0%,rgba(220,220,220,1) 100%) !important;
background-clip: padding-box !important;