Skip to content

Instantly share code, notes, and snippets.

View celiomarcos's full-sized avatar
:shipit:

Celio Marcos celiomarcos

:shipit:
View GitHub Profile
@brentd
brentd / gist:349955
Created March 31, 2010 04:56
delay jQuery's trigger() to prevent queueing
// Like jQuery's trigger(), only the firing of the event can be delayed by the
// specified duration (in milliseconds). The timer is reset on consecutive
// triggers with the same event name, so only the most recent event will be
// triggered when the duration ends. Useful if you need to prevent events from
// queueing up.
//
// $('#foo').bind('myEventName', function() {alert('hai')});
// ...
// $('#foo').delayedTrigger(1000, 'myEventName', 'event1');
// $('#foo').delayedTrigger(1000, 'myEventName', 'event2');
@chandlerprall
chandlerprall / threaded_download.py
Created June 9, 2011 17:41
Small Python multi-threaded file downloader
import urllib2
import threading
from Queue import Queue
import sys, os, re
class ThreadedDownload(object):
REGEX = {
'hostname_strip':re.compile('.*\..*?/', re.I)
}
@igorescobar
igorescobar / phonemask.js
Created September 14, 2012 20:35
Mascara Javascript para os novos telefones de São Paulo
// using: https://github.com/igorescobar/jQuery-Mask-Plugin
// version: v0.5.0+
var SPphoneMask = function(phone, e, currentField, options){
return phone.match(/^(\(?11\)? ?9(5[0-9]|6[0-9]|7[01234569]|8[0-9]|9[0-9])[0-9]{1})/g) ? '(00) 00000-0000' : '(00) 0000-0000';
};
$(".sp_celphones").mask(SPphoneMask, {onKeyPress: function(phone, e, currentField, options){
$(currentField).mask(SPphoneMask(phone), options);
}});
@crmccreary
crmccreary / AESCipher.py
Created May 20, 2013 02:17
Encryption using pycrypto, AES, and PKCS5 padding
from Crypto.Cipher import AES
from Crypto import Random
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
class AESCipher:
def __init__( self, key ):
"""
@anytizer
anytizer / css-debug.css
Created December 25, 2013 08:31
CSS Debugging by borders coloring of the tags
http://yysource.com/2011/03/debugging-with-css-outline-all-elements/
* { outline: 2px dotted red }
* * { outline: 2px dotted green }
* * * { outline: 2px dotted orange }
* * * * { outline: 2px dotted blue }
* * * * * { outline: 1px solid red }
* * * * * * { outline: 1px solid green }
* * * * * * * { outline: 1px solid orange }
* * * * * * * * { outline: 1px solid blue }
@mjohnsullivan
mjohnsullivan / download.py
Last active December 17, 2022 10:05
Python HTTP download with resume and optional MD5 hash checking
import os.path
import shutil
import hashlib
import logging
# Support both Python 2 and 3 urllib2 importing
try:
from urllib.request import urlopen, Request
except ImportError:
from urllib2 import urlopen, Request
@karlcow
karlcow / stupid-copy-protection.html
Created May 22, 2014 22:27
People trying to put copy protection on their content.
<!-- WP Content Copy Protection script by Rynaldo Stoltz Starts - http://securiilock.com -->
<div align="center"><noscript>
<div style="position:fixed; top:0px; left:0px; z-index:3000; height:100%; width:100%; background-color:#FFFFFF">
<div style="font-family: Tahoma; font-size: 14px; background-color:#FFF000; padding: 10pt;">Please enable your Javascript to see this page as it is meant to appear!</div></div>
</noscript></div>
<script type="text/javascript">
window.onload = function() {
disableSelection(document.body)
@dokenzy
dokenzy / aes_example_in_python.py
Last active May 3, 2020 07:09
AES Encrytion Example in Python
#-*- coding: utf-8 -*-
# Python 3.4
# author: http://blog.dokenzy.com/
# date: 2015. 4. 8
# References
# http://www.imcore.net/encrypt-decrypt-aes256-c-objective-ios-iphone-ipad-php-java-android-perl-javascript/
# http://stackoverflow.com/questions/12562021/aes-decryption-padding-with-pkcs5-python
# http://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256
@hemenkapadia
hemenkapadia / Ubuntu 14.04 on Optimus Laptop.txt
Last active May 2, 2023 20:44
[Ubuntu 14.04 on Optimus Laptop] Setting up Ubuntu 14.04 with nvidia drivers and CUDA on Dell 7559 Optimus laptop #Ubuntu #Nvidia #CUDA #setup
### NOTE ###
The below gist is converted to a blog post and available at below link. Refer that instead.
http://hemenkapadia.github.io/blog/2016/11/11/Ubuntu-with-Nvidia-CUDA-Bumblebee.html
#### Note about kernel versions ####
Between kernel versions 4.2 and 4.4 there are different options that need to bet set
to get this working. The same is highlighted below when necessary. I have not tested
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active June 15, 2024 15:20
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored