Skip to content

Instantly share code, notes, and snippets.

@giudinvx
giudinvx / slideshare-downloader.sh
Last active November 17, 2022 01:00
Slideshare Downloader
#!/bin/bash
#-----------------------------------------------
# Modify 4/08/2018 by giudinvx
# Email giudinvx[at]gmail[dot]com
#-----------------------------------------------
# Author: Andrea Lazzarotto
# http://andrealazzarotto.com
# andrea.lazzarotto@gmail.com
@huacnlee
huacnlee / will_paginate.js
Created August 24, 2011 01:41
使 WillPaginate 支持用左右键翻页
// Keyboard shortcuts for browsing pages of lists
(function($) {
$(document).keydown(handleKey);
function handleKey(e) {
var left_arrow = 37;
var right_arrow = 39;
if (e.target.nodeName == 'BODY' || e.target.nodeName == 'HTML') {
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
var code = e.which;
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@quietlynn
quietlynn / 12306.user.js
Created January 3, 2012 12:01
12306 Auto Query => A javascript snippet to help you book ticket
/*
12306 Auto Query => A javascript snippet to help you book tickets online.
Copyright (C) 2011-2012 Jingqin Lynn
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js
@kaichen
kaichen / Gemfile
Created January 9, 2012 03:35
play-with-em
source :rubygems
gem "eventmachine", "0.12.10"
gem "rack"
@mmrwoods
mmrwoods / postgres
Created January 20, 2012 13:47
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@mmrwoods
mmrwoods / mysql
Created January 20, 2012 13:49
MySQL maintenance crontab file
# note: MySQL_maintenance.pl can be obtained from http://danbuettner.net/mysql-tools/
# check, optimise and repair MySQL databases (extended check on Sunday, quick every other day)
15 3 * * 0 root nice -n 19 /usr/local/sbin/MySQL_maintenance.pl --check-type=extended --optimize --repair --exclude-dbs=information_schema
15 3 * * 1-6 root nice -n 19 /usr/local/sbin/MySQL_maintenance.pl --check-type=quick --optimize --repair --exclude-dbs=information_schema > /dev/null
# dump all mysql databases once every 24 hours
15 4 * * * root nice -n 19 mysqldump --opt --all-databases --allow-keywords | gzip -9 > /var/local/backup/mysql/mysql_all.sql.gz
@mmrwoods
mmrwoods / new_linode_centos6.markdown
Created February 7, 2012 11:39
Make me a new CentOS linode

Make me a new CentOS linode

Notes:

  • Instructions written for CentOS 6.3
  • Change, me, myhost, myip etc. to your username, hostname, ip address and so on.
  • Run all commands as root unless otherwise directed.
  • You might want to look at mounting /var and /home on separate partitions.
  • I've just allowed all members of the wheel group to operate as root. This is the height of laziness and highlights the fact that I'm just a developer that's stolen a sysadmin's
@fabriciocolombo
fabriciocolombo / PostgreSQL read-only user
Created April 24, 2012 20:57
PostgreSQL read-only user
GRANT CONNECT ON DATABASE $dbName TO $user;
GRANT USAGE ON SCHEMA $schema TO $user;
GRANT SELECT ON ALL TABLES IN SCHEMA $schema TO $user;
Default privileges
ALTER DEFAULT PRIVILEGES IN SCHEMA $schema
GRANT SELECT ON TABLES TO $user;
see more at http://www.postgresql.org/docs/9.0/static/sql-alterdefaultprivileges.html
@imperialwicket
imperialwicket / setup.sql
Last active November 10, 2022 00:26
PostgreSQL monthly table partitions
--
-- DEPRECATED GIST
-- **** Moved to a repo: https://github.com/imperialwicket/postgresql-time-series-table-partitions ****
--
-- You should check the repository, this gist won't receive updates.
--
--
--
--
--