Skip to content

Instantly share code, notes, and snippets.

View orlando's full-sized avatar
🦅

Orlando Del Aguila orlando

🦅
View GitHub Profile
@orlando
orlando / swap.md
Created July 11, 2016 17:25
Habilitar memoria swap en Ubuntu.

Memoria Swap en Ubuntu

Estos son los pasos a seguir para habilitar memoria swap en tu VPS corriendo Ubuntu, probablemente esto sirva para otros VPS

echo "Reemplazar 4G por el doble de memoria ram del sistema, ejemplo si tengo 1gb de ram, entonces colocar 2G)"
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
@orlando
orlando / helpers.scss
Created April 3, 2016 03:11
padding margins helpers
// padding/margins helpers
$sizes: (xs: 0.5rem, sm: 1rem, md: 1.5rem, lg: 2rem, xl: 2.5rem);
$properties: ('top', 'right', 'left', 'bottom');
@each $name, $value in $sizes {
@each $prop in $properties {
.margin-#{$prop}-#{$name} {
margin-#{$prop}: $value;
}
@orlando
orlando / htmlValidator.js
Last active December 21, 2015 04:39
poor's man javascript html validator
// Poor's man html Validator.
// https://gist.github.com/orlando/6251395
function validateHtml (htmlString) {
var htmlString, divElm, docFrag, docFragHtml;
htmlString = htmlString.replace(/ +/g, " ").toLowerCase();
htmlString = htmlString.replace(/\s*\/\s*>/g, ">");
divElm = document.createElement('div');
docFrag = document.createDocumentFragment();
docFrag.appendChild(divElm);
docFrag.querySelector('div').innerHTML = htmlString;
var teamboxChatSound = function teamboxChatSound () {
var ping, chatBody, observer, base64string, hidden, visibilityChange;
base64String = "data:audio/wav;base64,UklGRoAaAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YVwaAAB9fICEg355en2ChYF8e35/fX59foKDfHd6gIODgHp4fX99fYCAgIF/f4F9dHSAkpiFZlNjj7OlcEpYjrKWXlODt6xmMkqa1rZeKk2l2adNMG7FzXkvQJjbul8mT7LcoUYmbs3NfDE7mdquTyVfwduSNyl/1cdsKEuw2pM2LYXdyWQeP6jmrEEhb9TRZhtEruyuOxlmzeKCIzOW4bpKHV7C444pKobdyl0bSq7koDYrftLIYR9LrOGkOiNvy9Z7JDmc3KlBInHR03EaOKXkrj8ZbNHUdx80oeS2TRVaxtqKLTCV2rRWIFzD2I0xK4vcxWUfTLbcmzophdnGayRIr92kRihvys5/NkGZ0KhXMWa6yYY+PYnKs208V6O/lVhEdK6xhVdVgqSXdFtqj52Ka1xzkpuKbV90jJWKbmV3i5WEamd8lp1/X196nqJ8XWSHqJdpVWuZsI5bTHKpsYBRVoq0nGJJaae7iExGfry3cT9TmMWcUj1stcSBQUOEyLVkN1amzZRJO3TAv3Q6RZTSqFY0X7XMhEFBhMq0ZzpTo8uVTz1yvb91OkmVzapWMV+wyotBPH/Gu2YyUp/PnUU2cr3IeDNFkNKyUSxfs9SJNTqAyb1gL1elz5ZBOXW4vnI8VpG+n1NHd6i0d0JckbOaWFCAoqRwRWudrJFUToWoo3dMapyljF5VhKWffFdmkaGTbl1+mpeAZ3GRmYhzbIOXj4BxdYuPgXh4iZOBc3SClY13cHaIlIR1c4CUkHdqc46ch2tkepibgWZjgZyWeGBuj5yLaV9+m5
require 'active_record'
require 'database_cleaner'
connection_info = YAML.load_file("config/database.yml")["test"]
ActiveRecord::Base.establish_connection(connection_info)
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
var message = new MailMessage();
message.To.Add("user@example.com");
message.To.Add("user2@example.com");
message.From = new MailAddress("test@example.com");
message.Subject = "Test";
message.Body = "Test";
var client = new SmtpClient("localhost", 25);
auth = function(params) {
}
module.exports = auth
@orlando
orlando / gist:1989583
Created March 6, 2012 22:55
active admin handle many assets
f.inputs "Product images" do
f.has_many :assets do |p|
p.input :asset, :as => :file, :label => "Image",:hint => p.object.asset.nil? ? p.template.content_tag(:span, "No Image Yet") : p.template.image_tag(p.object.asset.url(:thumb))
p.input :_destroy, :as=>:boolean, :required => false, :label => 'Remove image'
end
end
f.inputs "Product details" do
f.input :category, :label => "Category", :hint => "Select one category"
f.input :height
@orlando
orlando / google_map.rb
Created December 25, 2011 02:52
google map
# File forked from github.com/kete/kete.. not my work
# what this does:
# * prepares google map accordingly for request type
# (form for baskets_controller#choose_type with empty map, display for index_page_controller#index,
# all other controllers#show, new, etc.)
# * adds view helpers for loading api js lib and initializing google map js and escaping js (i18n_js(key))
# * adds helpers for ExtendedFieldsHelper editor (including geocoding address form) and display
# * validates extended field ftype for map or map with address
module GoogleMap
@orlando
orlando / timeslider.js
Created December 20, 2011 22:16
jquery timeslider
$("li.month").click(function(e){
e.preventDefault();
var selected_month = $(this).closest('li').index();
$("#slider-range").slider("values",[Math.abs(moment([moment().year()]).diff(moment([moment().year()]).month(selected_month-1),'month')),Math.abs(moment([moment().year()]).diff(moment([moment().year()]).month(selected_month),'days'))]);
});