This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stat(path) | |
if File.exist?(path) | |
File.stat(path.to_s) | |
else | |
nil | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The below ,removes anything but ascii characters like: | |
variant_type.gsub!(/[^0-9A-Za-z.\-]/, '') | |
sql = "INSERT INTO my_table VALUES(#{rows[i].map{|x| x.inspect}.join(', ')})" | |
vs | |
sql = "INSERT INTO my_table VALUES(#{ ary.map{ |i| '"%s"' % i }.join(', ') })" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://donsnotes.com/tech/charsets/ascii.html | |
x1F | |
\x00 =>> null ... | |
Control Characters | |
CTRL (^D means to hold the CTRL key and hit d) | |
Oct Dec Char Hex Key Comments | |
\000 0 NUL \x00 ^@ \0 (Null byte) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in vim | |
echo &encoding | |
# count lines with grep | |
za:~ za$ grep -c ".*" file.txt | |
2 for Hexadecimal, you could use hd | |
echo Hello world | hd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bitwise , beause we operate on bits ..example the number 5 has the binary represenation of 01100001 . Bits can also be translated into | |
true or false.where repersenting a number where 1 will be false and 0 will be true. | |
Given two binary strings, complete the following logic operation: | |
01101 xor 01101 | |
The answer is : | |
01101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- <%= link_to ' log out ', destroy_user_session_path, :method => :delete %> | |
<%= link_to( | |
#want to read more about this helper ...content_tag =>> http://apidock.com/rails/ActionView/Helpers/TagHelper/content_tag | |
content_tag( | |
# adda div or h3 here for "log out" | |
:i, | |
nil, | |
class: 'fa fa-user-times' | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find out if you are root or not for admin tasks. | |
(( EUID )) && { echo 'Run this script with root priviliges.'; exit 1; } || echo 'Running as root, starting service...' | |
find userID: | |
]$ id -u | |
44502 | |
#za:~ za$ brew search /*\net*/ | |
#!/bin/sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Print keys and values from hash | |
The \A and \Z are just like "^" and "$" | |
my @keys; | |
while (<>) { | |
chomp; # Or: s/\s+\z//; | |
push @keys, $_; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# returns back what was changed after gitting pull locally. | |
git diff HEAD^^ HEAD nmae/of/thefile.rb | |
FYI , | |
# this will show what was last added your local "showing newly added changes" | |
git diff --color HEAD^ HEAD | |
# this will do the reverse .. it will show the commit prior to pulling from the remote. | |
git diff --color HEAD HEAD^ |
OlderNewer