Skip to content

Instantly share code, notes, and snippets.

View gouravtiwari's full-sized avatar

Gourav Tiwari gouravtiwari

View GitHub Profile
@ivanyv
ivanyv / application.amp.erb
Created December 12, 2015 02:51
Easy Google AMP on Rails
<html>
<head>
<link rel="canonical" href="<%= current_uri_sans_amp %>">
</head>
...
</html>
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active October 1, 2024 17:10
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@tkh44
tkh44 / FileController.js
Last active March 10, 2020 09:04
Simple file upload for sails.js
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
@gouravtiwari
gouravtiwari / jenkins_setup.sh
Last active April 24, 2019 21:00
Jenkins setup on SUSE
# 1. Install jenkins
sudo zypper addrepo http://pkg.jenkins-ci.org/opensuse/ jenkins
sudo zypper install jenkins
# You would be asked something like this:
# Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): t
# Overall download size: 115.9 MiB. After the operation, additional 159.9 MiB will be used.
# Continue? [y/n/?] (y): y
# 2. Start jenkins
sudo /etc/init.d/jenkins start
@leveret
leveret / SQLite 3.6
Created September 30, 2013 11:34
SQLite3 for linux
wget http://www.sqlite.org/sqlite-autoconf-3070603.tar.gz
l
find / -name sqlite*
tar -xvf sqlite-autoconf-3070603.tar.gz
l
cd sqlite-autoconf-3070603/
l
./configure
l
make
@gouravtiwari
gouravtiwari / turtle.rb
Last active December 22, 2015 02:29
turtuled
# Turtle shapes
# Not at all necessory, but just to show that you can define attr_accessor from module as well
module AttrLoader
def attr_loader(*attrs)
attr_accessor *attrs
end
end
@epicserve
epicserve / redis_key_sizes.sh
Last active November 10, 2024 13:47
A simple script to print the size of all your Redis keys.
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@ck3g
ck3g / autocomplite.css.scss
Last active May 29, 2020 18:02
Twitter bootstrap + rails3-jquery-autocomplete gem styles
ul.ui-autocomplete {
margin-top: 2px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
@NapoleonWils0n
NapoleonWils0n / curl_time_to_first_byte.sh
Created November 3, 2012 22:33
bash: curl time to first byte
curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" http://inserturl.here