Skip to content

Instantly share code, notes, and snippets.

@stream7
stream7 / migration_integer_limit_option
Created July 7, 2011 14:09
Rails migrations integer :limit option
literally always have to look up the meaning of :limit in migrations when it comes to integer values. Here's an overview. Now let's memorise it (oh, this works for MySQL, other databases may work differently):
:limit Numeric Type Column Size Max value
1 tinyint 1 byte 127
2 smallint 2 bytes 32767
3 mediumint 3 byte 8388607
nil, 4, 11 int(11) 4 byte 2147483647
5..8 bigint 8 byte 9223372036854775807
Note: by default MySQL uses signed integers and Rails has no way (that I know of) to change this behaviour. Subsequently, the max. values noted are for signed integers.
@stream7
stream7 / mysqldump_single_table
Created August 22, 2011 13:52
Backuping and restoring a single table using mysqldump
Backuping a single table from a database
mysqldump -u -p database_one -h host table_name > /var/www/backups/table_name.sql
Backuping a single table from a database with query
mysqldump -u #{user} -p#{pass} -h #{server} -nt --databases #{database} --tables #{table} --where="#{query}" > example.sql
mysqldump -u root -prootpass -h ssserver -nt --databases example_development --tables products --where="id > 7970001" > products.sql
-n -t for --no-create-db --no-create-info
mysqldump -u root -pmagrathea -h ssserver --no-create-db --no-create-info --databases marvin_real3 --tables products --where="id > 7970001" > pr2.sql
Restoring the table into another database
Verifying my Blockstack ID is secured with the address 1N4JtW2rHFdMR3QeuCSUvif4aWcHCRt5DR https://explorer.blockstack.org/address/1N4JtW2rHFdMR3QeuCSUvif4aWcHCRt5DR
@stream7
stream7 / mxSwimlaneLayout.js
Created November 7, 2017 16:48 — forked from davidjgraph/mxSwimlaneLayout.js
23.09.2013 Swimlane layout fix
/**
* $Id: mxSwimlaneLayout.js,v 1.3 2013/09/23 14:11:22 david Exp $
* Copyright (c) 2005-2012, JGraph Ltd
*/
/**
* Class: mxSwimlaneLayout
*
* A hierarchical layout algorithm.
*
* Constructor: mxSwimlaneLayout
@stream7
stream7 / gist:550622206741ca5362599bbcd16eaeb8
Created September 11, 2016 11:21
how to download a website with wget
# download html
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--no-parent \
--restrict-file-names=nocontrol \
@stream7
stream7 / gist:4e0037fa497664987455cdb48aff9de9
Created April 3, 2016 08:07
wget commands for downloading a whole website
// Get the pages
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--no-parent \
--restrict-file-names=nocontrol \
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
#
# Update 2013-06-24: added -w0 option to prevent truncated lines
require 'base64'
data=`ioreg -l -w0 -d0 -r -c AppleDisplay`
@stream7
stream7 / toUpperCase Greek
Last active December 22, 2015 20:09
toUpperCase for Greek chars
/*global define*/
'use strict';
define(function () {
var map = {
'ά': 'A',
'Ά': 'Α',
'έ': 'Ε',
'Έ': 'Ε',
'ή': 'Η',
'Ή': 'Η',
@stream7
stream7 / dabblet.css
Created July 12, 2013 20:39 — forked from LeaVerou/dabblet.css
Flexible buttons with ems (duh!)
/**
* Flexible buttons with ems (duh!)
*/
body {
font-family: sans-serif
}
button {
padding: .5em .8em .4em;
@stream7
stream7 / gist:5671932
Created May 29, 2013 17:05
bitbucket exception
$ git push --force
Counting objects: 375, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (274/274), done.
Writing objects: 100% (277/277), 47.32 KiB, done.
Total 277 (delta 199), reused 0 (delta 0)
remote: Traceback (most recent call last):
remote: File "/opt/python/domains/bitbucket.org/current/bitbucket/scripts/git/hooks/pre-receive", line 29, in <module>
remote: from bitbucket.apps.repo2.hooks import prehooks
remote: File "/opt/python/domains/bitbucket.org/current/bitbucket/apps/repo2/hooks.py", line 16, in <module>