Skip to content

Instantly share code, notes, and snippets.

open BibliotecaT0
open System
[<EntryPoint>]
let main argv =
let interfaz = new Interfaz()
System.Console.Write("Solo llego aquí si he abierto un archivo\n")
def valid_password?(password)
self.password_hash == BCrypt::Engine.hash_secret(password, self.password_salt)
end
def encrypt_password
if password.present?
self.password_salt = BCrypt::Engine.generate_salt
self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)
end
end
@muZk
muZk / gist:079a0f9d2bfbede37f68
Last active August 29, 2015 14:01
mini tutorial de la cosa de ajax para proyecto

El refactor que hice aplica para todo lo que tenga que ver con un comportamiento como sigue:

  1. Crear alguna entidad a través de un modal.
  2. Al crearlo, agregar la actividad creada a algún div de la vista.
  3. Todo esto, a través de ajax (sin que se recargue la página).

Hay varias cosas que tienen ese comportamiento (agregar usuarios, agregar tareas, etc), y para que sea automático hay que hacer lo siguiente:

  1. El modal y el form deben tener un ID muy parecido. Deben terminar en -modal y en -form respectivamente. Por ejemplo, si mi modal tiene id igual a add-user-modal, entonces el id del form debe ser add-user-form.
var myController = new Controller();
// EL * es para decir antes de cualquier acción ejecutar este middleware
myController.before('*', function(next){
if(typeof this.req.user === 'undefined'){
return next(new Error('Unauthorized'));
}
next();
});
require 'csv'
CSV.foreach 'data/ratings.csv' do |row|
puts row
end
module SpreadsheetReader
=begin
class Base
def self.attr_accessor(*vars)
@attributes ||= []
@attributes.concat vars
super(*vars)
end
@muZk
muZk / gist:09e9f26f4aabdfd95690
Last active August 29, 2015 14:07
Be Awesome
var sad = (function(){
var areYouSad = true;
Boolean.prototype.stop = function(){
areYouSad = false;
}
return function(){
return areYouSad;
var app = angular.module("Projects", ["ngRoute"]);
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when("/projects", { templateUrl: "<%= asset_path('projects/index.html') %> ", controller: "ProjectsIndexCtrl" })
.when("/projects/:id", { templateUrl: "<%= asset_path('projects/show.html') %> ", controller: "ProjectsShowCtrl" })
.otherwise({ redirectTo: "/projects" });
});
library DamageExtension requires Damage
// percent from 0 to 100
function Damage_BlockPercent takes real percent returns nothing
call Damage_Block( GetEventDamage() * percent/100)
endfunction
endlibrary