Skip to content

Instantly share code, notes, and snippets.

View edymerchk's full-sized avatar
:shipit:
Shipping

Edy Laverde edymerchk

:shipit:
Shipping
  • Medellin
View GitHub Profile
@edymerchk
edymerchk / form.html.erb
Last active January 3, 2016 17:39
select with extra attrs in each option
<%= f.select :invited_by_id, collection: User.approved.map {|u| [u.doc, u.id, {"names" => u.names}]} %>
<label id="name"> -- </label>
@edymerchk
edymerchk / directive.coffee
Created January 22, 2014 21:22
Only allow to put digits directive
.directive "onlyDigits", ->
restrict: "A"
require: "?ngModel"
link: (scope, element, attrs, ngModel) ->
return unless ngModel
reg = /^-?\d*\.?\d*$/
ngModel.$parsers.unshift (inputValue) ->
digits = inputValue.split("").filter((s) ->
not !reg.test(s)
).join("")
directive "ngBlur", ->
(scope, elem, attrs) ->
elem.bind "blur", ->
scope.$apply attrs.ngBlur
directive "ngFocus", ($timeout) ->
(scope, elem, attrs) ->
scope.$watch attrs.ngFocus, (newval) ->
if newval
// separator inside forms
form hr{
display:block;
border:none;
color:white;
height:1px;
background:black;
background: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 350, from(#000), to(#fff));
}
htmlEntities: (str) ->
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;')
#init.d service for nginx
wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults
@edymerchk
edymerchk / add-swap-on-ubuntu.sh
Created February 18, 2014 15:39
how-to-add-swap-on-ubuntu-12-04
full explanation: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
sudo mkswap /swapfile
sudo swapon /swapfile
echo 0 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 0 | sudo tee -a /etc/sysctl.conf
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
Date (Year, Month, Day):
%Y - Year with century (can be negative, 4 digits at least)
-0001, 0000, 1995, 2009, 14292, etc.
%C - year / 100 (round down. 20 in 2009)
%y - year % 100 (00..99)
%m - Month of the year, zero-padded (01..12)
%_m blank-padded ( 1..12)
%-m no-padded (1..12)
%B - The full month name (``January'')
Installation guide for Ruby stack in Ubuntu (Work In Progress)
Open your terminal and copy and paste the following commands:
# This will install: git, ruby and zsh:
sudo apt-get update
sudo apt-get install build-essential git zlib1g-dev openssl libopenssl-ruby1.9.1 libssl-dev libruby1.9.1 libreadline-dev libcurl4-gnutls-dev librtmp-dev curl -y
sudo apt-get install zsh -y
File.write("server.pid", Process.pid)
trap("SIGINT") do
File.delete("server.pid")
exit
end