Skip to content

Instantly share code, notes, and snippets.

View edymerchk's full-sized avatar
:shipit:
Shipping

Edy Laverde edymerchk

:shipit:
Shipping
  • Medellin
View GitHub Profile
@edymerchk
edymerchk / usario_empresa.sql
Last active December 12, 2015 10:29
SQL DDL with constraints and composite fk
CREATE TABLE TEO_USUARIOS
(
CDTIPO_DOCUMENTO VARCHAR2(2) NOT NULL
, CDNUMERO_DOCUMENTO VARCHAR2(16) NOT NULL
, DSNOMBRES VARCHAR2(50)
, DSAPELLIDOS VARCHAR2(50)
, DSCLAVE VARCHAR2(4)
, CONSTRAINT TEO_USUARIOS_PK PRIMARY KEY
(
CDTIPO_DOCUMENTO
@edymerchk
edymerchk / gist:5650943
Created May 25, 2013 22:10
REST routes for node.js project
URL_ROOT = "/api"
## Traditional REST
app.get "#{URL_ROOT}/:controller" , (req, res, next) ->
routeMvc(req.params.controller, "index",req,res, next)
app.post "#{URL_ROOT}/:controller", (req, res, next) ->
routeMvc(req.params.controller, 'create', req, res, next)
app.get "#{URL_ROOT}/:controller/:id" , (req, res, next) ->
@edymerchk
edymerchk / Shuffle
Created August 1, 2013 20:56
shuffle
shuffle = (o) ->
i = o.length
while i
j = Math.floor(Math.random() * i)
x = o[--i]
o[i] = o[j]
o[j] = x
o
@edymerchk
edymerchk / %w(…) VS array [..]
Last active December 24, 2015 00:19
%w(…) VS array [..]
require 'benchmark'
n = 10000000
Benchmark.bm(10) do |b|
b.report('%w') { n.times { %w[hugo paco luis] } }
b.report('explicit') { n.times { ['hugo', 'paco', 'luis'] } }
end
# Test 1:
@edymerchk
edymerchk / LoginMacros Rspec.rb
Last active December 25, 2015 14:39
LoginMacros Rspec
#spec/spec_helper.rb
#add this
config.include LoginMacros
#features/private_area_specs.rb
before :each do
login @user
end
it 'works' do
@edymerchk
edymerchk / glyph.rb
Last active December 27, 2015 12:59
Bootstrap 2
def glyph(*names)
content_tag :i, nil, :class => names.map{|name| "icon-#{name.to_s.gsub('_','-')}" }
end
link_to glyph(:eye_open, :white), content
@edymerchk
edymerchk / .htaccess
Created November 7, 2013 21:14
no-cache Apache
ExpiresActive On
ExpiresDefault A0
<FilesMatch "\.(html|js|css|htm)$">
ExpiresDefault A0
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
@edymerchk
edymerchk / display_base_errors.rb
Created December 15, 2013 19:23
display_base_errors rails for flash msg
def display_base_errors resource
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?)
messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-block">
<button type="button" class="close" data-dismiss="alert">&#215;</button>
#{messages}
</div>
HTML
html.html_safe
@edymerchk
edymerchk / loop_rspec.sh
Created December 20, 2013 22:09
run specs several times
for i in `seq 3`; do bundle exec rspec; done
class Hash
def method_missing(method, *opts)
m = method.to_s
if self.has_key?(m)
return self[m]
elsif self.has_key?(m.to_sym)
return self[m.to_sym]
end
super
end