Skip to content

Instantly share code, notes, and snippets.

View zirosas's full-sized avatar

Jiro Sasamoto zirosas

View GitHub Profile
@zirosas
zirosas / zebratable.css
Created August 17, 2012 04:28
Table CSS Zebra striping
table {
width: 100%;
border-collapse: collapse;
table-layout:fixed;
font-size: 10px;
}
/* Zebra striping */
tr:nth-of-type(odd) {
background: #eee;
}
@zirosas
zirosas / Typing view on Canvas
Created April 28, 2013 21:54
Typing view of character on HTML5 Canvas.
function typing() {
var canvas = document.getElementById('canvas');
if (!canvas || !canvas.getContext) return false;
var ctx = canvas.getContext('2d');
var x = 0;
var myname = ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'];
name();
function name() {
for (var i = 0; i < myname.length; i++) {
@location_list = [
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]
<%= raw @location_list.as_json %>
@zirosas
zirosas / Rails add bootstrap icon to link
Last active December 16, 2015 21:29
Rails add bootstrap icon to link
@zirosas
zirosas / bootstrap typeahead multiple selection
Created May 11, 2013 00:26
bootstrap typeahead multiple selection
function extractor(query) {
var result = /([^,]+)$/.exec(query);
if(result && result[1])
return result[1].trim();
return '';
}
var subjects = <%= raw autohash.to_json %>;
$('#search').typeahead({
source: subjects,
@zirosas
zirosas / bootstrap typeahead ajax
Created May 11, 2013 00:41
bootstrap typeahead ajax
$(function(){
$('#typeahead').typeahead({
source: function (query, process) {
return $.getJSON(
'lookup.json',
{ query: query },
function (data) {
return process(data);
});
}
@zirosas
zirosas / Display value of input in DIV object jQuery
Created May 14, 2013 01:49
Display value of input in DIV object jQuery
$(function() {
$('#someInput').keyup(function() {
$('#someDiv').text($(this).val());
});
});
@zirosas
zirosas / if you are at the site root?
Created May 29, 2013 04:09
if you are at the site root?
if you are at the site root:
current_page?('/')
or, if you defined map.root in your config/routes.rb:
current_page?(root_url)
@zirosas
zirosas / gist:5719892
Created June 6, 2013 07:26
The command output string is sent to the operating system as a command to be executed (under windows operating system, we have sent the dir command), whereupon the output of the command (dir on a command window would display all the files and sub directories in your folder) is then displayed by puts. On Linux and Mac, you can instead do:
puts `ls`
@zirosas
zirosas / Decrypt the WordPress password
Created June 26, 2013 19:53
Decrypt the WordPress password. include('classhash.php')
$username = '';
$password = '';
$strSql = "SELECT user_pass FROM wp_users WHERE user_login = '$username'";
$result = mysql_query($strSql);
$row = mysql_fetch_array($result);
$encpass = $row['user_pass'];
if(!is_null($encpass)) {
include('classhash.php');