Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
chris-ramon / gist:1996938
Created March 7, 2012 22:59 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
// cesar encrypt
var msg = "quisieraquelaclaseseatemprano";
var letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","ñ","o","p","q","r","s","t","u","v","w","x","y","z" ];
var a = 3;
var b = 5;
var result = []
for (var i = 0; i < msg.length ; i ++){
for(var j = 0; j < letters.length ; j ++) {
if(msg[i] == letters[j]) { var p=((j*a+b) % 27 ); result.push(letters[p]); }
@chris-ramon
chris-ramon / redactorjs
Created June 9, 2012 20:41
redactorjs init
<!DOCTYPE html>
<html>
<head>
<title>Redactor</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="css/style.css" />
@chris-ramon
chris-ramon / gist:2915375
Created June 12, 2012 05:38
detect scrollbar changed
$(window).on('scroll', function(){ if( $(window).height() < $(window).scrollTop() ){ console.log($(window).scrollTop() ) } });
@chris-ramon
chris-ramon / JavaCandR.sublime-build
Created July 6, 2012 22:57 — forked from DevinClark/JavaCandR.sublime-build
This is a build script for Sublime Text 2 that will compile and run the open java file by simply pressing cmd + B. I am very new at Java so feel free to point out problems with this script. You can just drop this file in the User Packges folder and restar
{
"cmd": ["javac", "$file_name"],
"cmd": ["java", "$file_base_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.java"
}
@chris-ramon
chris-ramon / ac.rb
Created October 11, 2012 13:01
activemerchant-error
require 'rubygems'
gem 'active_merchant', '~> 1.3.1'
# Send requests to the gateway's test servers
ActiveMerchant::Billing::Base.mode = :test
Create a new credit card object
credit_card = ActiveMerchant::Billing::CreditCard.new(
:number => '4111111111111111',
:month => '8',
@chris-ramon
chris-ramon / postfix_solver.cs
Created October 14, 2012 02:10
solves postfix expression
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace hadigari
{
class Calculator
{
double last_element;
FOREIGN KEY (`plan_id`) REFERENCES `plans` (`id`)) ENGINE=InnoDB
FOREIGN KEY (`plan_id`) REFERENCES `panel_plans` (`id`)) ENGINE=InnoDB
### route
get "/gateways/update-default-gateway/:id/:action", :to => "panel/gateways#update_default_gateway" ,\
:as => 'update_default_gateway'
### path in views
<a href="<%= update_default_gateway_path :id => panel_gateway.id, :action => 'disable' %>" class="">Disable</a>