Skip to content

Instantly share code, notes, and snippets.

View blackjid's full-sized avatar
🎹

Juan Ignacio Donoso blackjid

🎹
View GitHub Profile
@blackjid
blackjid / dateDjango.js
Created April 19, 2012 16:53
Create a Javascript date object with the time synced with the server time. The code must be processed in the server.
// Django template
(function(){
var _date = new Date();
date = {
gmtOffset: {% now "Z" %},
offset: {% now "U" %} - Math.round(_date.getTime() / 1000),
now: function(unix){
if(unix)
return Math.round(_date.getTime() / 1000) + this.offset + _date.getTimezoneOffset()*60*1000 + this.gmtOffset*1000;
return new Date(((Math.round(_date.getTime() / 1000) + this.offset)*1000) + _date.getTimezoneOffset()*60*1000 + this.gmtOffset*1000);
@blackjid
blackjid / gist:2628871
Created May 7, 2012 16:41
A clean way to get data from a form element using the submit event
//Requires underscore, jquery
$(document).on('submit', 'selector.to.the.form.element', function(e){
// The the data from the form
var formData = _.reduce($(e.currentTarget).serializeArray(), function(memo, val){
memo[val.name] = val.value;
return memo;
},{});
@blackjid
blackjid / gist:3915929
Created October 19, 2012 02:30
History search binding
bind '"\M-[A":history-search-backward'
bind '"\M-[B":history-search-forward'
@blackjid
blackjid / nginx-init-deb.sh
Created January 23, 2013 16:03
Init script for Nginx in Debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@blackjid
blackjid / STInstallation.md
Last active December 14, 2015 17:09
All my settings for Sublime Text

Syntax Highlights

  • Apiary
  • Yaml
  • Scss
  • nginx
  • less

Packages

  • SublimeLinter
  • SideBarEnhancements
# pushState friendly!
# The setup:
# * website name is `site.com`
# * the API for your running on localhost:3000
# * the root for API calls is at `/api`, and you have authentication routes with root `/auth` (both go to localhost:3000)
# * javascript app is located at `/path/to/javascript/app`
# Assuming you have your server for API calls at localhost port 3000
upstream api_sitecom {
server localhost:3000;
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@blackjid
blackjid / gulpfile.js
Created April 9, 2014 17:59
Gulp Ionic Server + Livereload + Proxy
var gulp = require('gulp');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var connect = require('gulp-connect');
var paths = {
css: ['./www/css/**/*.css'],
js: ['./www/js/**/*.js'],
@blackjid
blackjid / vj-story.rb
Created April 23, 2014 21:28
Vj Archive test for rhinobird
def prepare
# Download the files
for stream in @stream_urls do
system("curl -O https://s3.amazonaws.com/media-rhinobird.tv/#{stream[:name]}") unless File.exists?(stream[:name])
end
# Create a tmp dir
system("rm -rf tmp && mkdir tmp")
system("rm -f video_story.txt")
system("rm -f audio_story.txt")
@blackjid
blackjid / README.md
Last active August 29, 2015 14:01
Google Calendar Attendees widget for Dashing

Description

A Dashing widget for displaying the number of attendees for a specific calendar event on Google Calendar

It's specially designed to be used against a recursive event. For example, we use it at platanus to show how many people and who is going to have lunch in the office.

screen shot

Made by platanus in Chile