Skip to content

Instantly share code, notes, and snippets.

View alchaplinsky's full-sized avatar

Alex Chaplinsky alchaplinsky

View GitHub Profile
@alchaplinsky
alchaplinsky / gist:2013806
Created March 10, 2012 22:54
Font-face for custom fonts
@font-face{
font-family: 'font-name';
src: url('font-name');
src: url('font-file-name.eot?#iefix') format("embedded-opentype"),
url('font-file-name.woff') format('woff'),
url('font-file-name.ttf') format('truetype'),
url('font-file-name.svg#font-name') format('svg');
font-weight: normal;
font-style: normal;
}
@alchaplinsky
alchaplinsky / example.js
Created July 24, 2012 12:11 — forked from addyosmani/example.js
Mediator pattern
// Example 1
mediator.name = 'Doug';
mediator.subscribe('nameChange', function(arg){
console.log(this.name);
this.name = arg;
console.log(this.name);
});
mediator.publish('nameChange', 'Jorn');
@alchaplinsky
alchaplinsky / gist:3684212
Created September 9, 2012 13:12
Clean up expired Active Record sessions
namespace :db do
namespace :sessions do
desc "Clean up expired Active Record sessions (updated before ENV['EXPIRE_AT'], defaults to 1 month ago)."
task :expire => :environment do
Rails.logger.info "Cleaning up expired sessions..."
puts "Cleaning up expired sessions..."
time = ENV['EXPIRE_AT'] || 1.month.ago.to_s(:db)
rows = ActiveRecord::SessionStore::Session.delete_all ["updated_at < ?", time]
Rails.logger.info "Expired sessions cleanup: #{rows} session row(s) deleted."
puts "Expired sessions cleanup: #{rows} session row(s) deleted."
@alchaplinsky
alchaplinsky / cookie.coffee
Created December 9, 2012 12:22
Cookie management class
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
gzip on;
gzip_http_version 1.1;
gzip_comp_level 6;
@alchaplinsky
alchaplinsky / gist:1b9dc421fe02eb594f18
Created May 27, 2015 16:25
Capistrano 3 ask secretly
def ask_secretly(key, default=nil)
require "highline"
set key, proc{
hint = default ? " [#{default}]" : ""
answer = HighLine.new.ask("Enter #{key}#{hint}: ") do |q|
q.echo = false
end.to_s
}
end
$.fn.extend numMaxlength: (options) ->
@each ->
$this = $(this)
$this.keydown (e) =>
if !(isNumber(e) || isAllowedKey(e)) || ( isMaxLength($this) && isNumber(e) )
e.preventDefault()
isNumber = (event) ->
numberKeys = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
numberKeys.indexOf(event.keyCode) != -1
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
@alchaplinsky
alchaplinsky / server.js
Last active August 12, 2019 13:08
Sending email with Express and nodemailer
const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");
const nodemailer = require("nodemailer");
const app = express();
app.use(cors({ origin: "*" }));
app.use(bodyParser.json());
"Project","Client","Description","Task","User","Email","Tags","Billable","Start Date","Start Time","End Date","End Time","Duration (h)","Duration (decimal)","Billable Rate (COP)","Billable Amount (COP)"
"2020-24 Puentes Variante Lorica_El Condor","","Revisión planos pruebas de carga","","Agonzalez","test@example.com","","Yes","03/09/2020","4:30 PM","03/09/2020","5:30 PM","1:00","1.00","86470.00","86470.00"
"2020-39 Transmilenio Av. 68 Tramo 4_Pavcol","","Reunión","","Aserrano","test1@example.com","","Yes","03/09/2020","4:00 PM","03/09/2020","5:00 PM","1:00","1.00","234942.00","234942.00"
"2018-81 AcompañamientoMar2_CHEC","","Box Culvert "K11+218 UF4","","Dmontoya","test2@example.com","","Yes","03/09/2020","2:00 PM","03/09/2020","6:00 PM","4:00","4.00","67941.00","271764.00"