Skip to content

Instantly share code, notes, and snippets.

@jeduan
jeduan / index.js
Created Mar 20, 2014
Error handling in express 4
View index.js
var express = require('express'),
logger = require('morgan')
var app = express();
var env = process.env.NODE_ENV || 'development';
var silent = env === 'test'
app.set('port', +process.env.PORT || 3000)
if (env === 'development') {
View db.js
var _ = require('underscore')
var config = require('../../config')
var mongoose = require('mongoose')
mongoose.connect(config.mongoUrl)
var db = mongoose.connection
mongoose.set('debug', !!config.mongoDebug)
db.on('error', function () {
return console.error.bind(console, '[mongo]: ')
})
@jeduan
jeduan / keybase.md
Last active Aug 29, 2015
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am jeduan on github.
  • I am jeduan (https://keybase.io/jeduan) on keybase.
  • I have a public key whose fingerprint is B70B 4F2F 27B9 18F5 4100 0EBE 6709 8BD2 7AEF CF68

To claim this, I am signing this object:

@jeduan
jeduan / wifi-password.rb
Last active Aug 29, 2015
Homebrew Formulae for wifi-password
View wifi-password.rb
class WifiPassword < Formula
homepage "https://github.com/rauchg/wifi-password"
url "https://github.com/rauchg/wifi-password/archive/0.0.1.tar.gz"
version "0.0.1"
sha1 "7f92794a3a04762009a0c4525cbf2aa851002289"
def install
bin.install "wifi-password.sh" => "wifi-password"
end
end
View gist:74659
public List<TableroControlTO> obtenTableroColegio(int cveunidad, int subgrupo, String anio) {
List<TableroControlTO> unidades = new ArrayList<TableroControlTO>();
Connection con = null;
try {
con = getDataSource().getConnection();
PreparedStatement pstm = con.prepareStatement("SELECT * FROM sistema.tableroestatal(?, ?, ?)");
pstm.setInt(1, cveunidad );
pstm.setInt(2, subgrupo);
View gist:1142547
$ dmesg
:0: [sda] Unhandled error code
[327491.642630] sd 0:0:0:0: [sda] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[327491.642636] sd 0:0:0:0: [sda] CDB: Read(10): 28 00 00 f8 c0 c7 00 00 08 00
[327491.642648] end_request: I/O error, dev sda, sector 16302279
[327491.646981] type=1505 audit(1313152772.682:1388): operation="profile_replace" pid=31237 name="/usr/sbin/mysqld"
[327521.806796] sd 0:0:0:0: [sda] Unhandled error code
[327521.806800] sd 0:0:0:0: [sda] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
[327521.806806] sd 0:0:0:0: [sda] CDB: Read(10): 28 00 00 f8 c0 c7 00 00 08 00
[327521.806818] end_request: I/O error, dev sda, sector 16302279
@jeduan
jeduan / reveal_ajax.js
Created Feb 9, 2012
Use Zurb reveal with ajax
View reveal_ajax.js
$('a.reveal').click(function(event) {
event.preventDefault();
var $div = $('<div>').addClass('reveal-modal').appendTo('body'),
$this = $(this);
$.get($this.attr('href'), function(data) {
return $div.empty().html(data).append('<a class="close-reveal-modal">&#215;</a>').reveal();
});
});
@jeduan
jeduan / postcard-responsive.html
Created May 21, 2012
Responsive email template
View postcard-responsive.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<!-- Facebook sharing information tags -->
<meta property="og:title" content="*|MC:SUBJECT|*" />
<title>*|MC:SUBJECT|*</title>
@jeduan
jeduan / Gemfile
Created Sep 13, 2012
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
View Gemfile
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
View mysql2sqlite.sh
#!/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