Skip to content

Instantly share code, notes, and snippets.

@DiegoSeC
DiegoSeC / turn-angular.coffee
Created July 4, 2013 23:31
Turnjs and Angularjs, I don't know if this is the best way to do it but You know is much better this than nothing :). Im using AngularUI for the views, if you haven't used it before, well... between us You have to use it jajaja just saying :D!
ALGRAF = angular.module('algraf', ['ui.state'])
ALGRAF.config ($routeProvider, $interpolateProvider, $stateProvider) ->
$interpolateProvider.startSymbol('{[')
$interpolateProvider.endSymbol(']}')
$stateProvider
.state 'index'
url: '/'
views:
@DiegoSeC
DiegoSeC / chunk.coffee
Created July 11, 2013 23:07
Split array in chunks using underscore.js
# Thanks to: http://stackoverflow.com/questions/8566667/split-javascript-array-in-chunks-using-underscore-js
_.mixin
chunk: (array, unit) ->
result = _.groupBy array, (element, index) ->
Math.floor index / unit
_.toArray result
data = [1,2,3,4,5,6,7,8,9]
# We pass the array and the size of the chunk
list = _.chunk data, 2
@DiegoSeC
DiegoSeC / facebook.coffee
Last active December 20, 2015 04:39
Update your facebook profile with Casper
console.log "Magic Start Here"
casper = require('casper').create()
casper.start "http://facebook.com", ->
@echo "Loggin... "
@fill "form[id='login_form']", { email: "[email protected]", pass: "yourpassword", persistent: true }, true
@capture 'facebook.png'
casper.then ->
@echo 'Profile... '
@DiegoSeC
DiegoSeC / Callback.java
Created November 15, 2013 17:01
Callback on Java
package com.nevacom.vigi.intface;
public interface Callback<T> {
public void invoke(T arg);
}
/* Nh?c */
var parent = document.getElementsByTagName("html")[0];
var _body = document.getElementsByTagName('body')[0];
var _div = document.createElement('div');
_div.style.height = "25";
_div.style.width = "100%";
_div.style.position = "fixed";
_div.style.top = "auto";
_div.style.bottom = "0";
_div.align = "center";
<?php
// Returns the value of the expression, take care if you use isset or some function who evaluate the variable
// because will return true or the response of the function.
$x = "Hey";
echo $x ?: "The variable doesn't exist";
echo (isset($y) ?: "The variable doesn't exist");
@DiegoSeC
DiegoSeC / Facebook.php
Last active September 25, 2015 13:30
A Simple library for the new Facebook SDK.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( session_status() == PHP_SESSION_NONE ) {
session_start();
}
// Autoload the required files
require_once( APPPATH . 'libraries/vendor/autoload.php' );
use Facebook\FacebookRedirectLoginHelper;
@DiegoSeC
DiegoSeC / start.sh
Created April 9, 2019 19:35
# Docker Start Script Template
#!/bin/bash
# Stop docker containers if exists
names=$(docker ps --format "{{.Names}}")
if [ ! -z "$names" ]
then
printf "\n\e[1;31mKilling the following containers:\e[0m\n\n"
while read -r name
@DiegoSeC
DiegoSeC / start.sh
Last active July 31, 2022 01:12
Docker Compose Start Script Template
#!/bin/bash
# Stop docker containers if exists
names=$(docker ps --format "{{.Names}}")
if [ ! -z "$names" ]
then
printf "\n\e[1;31mKilling the following containers:\e[0m\n\n"
while read -r name