Skip to content

Instantly share code, notes, and snippets.

Nayan Hajratwala nhajratw

Block or report user

Report or block nhajratw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:f09291aa942a4fa8d860
#!/usr/bin/env ruby
#
#
require 'net/http'
my_ip = Net::HTTP.get(URI('http://icanhazip.com'))
system "aws ec2 authorize-security-group-ingress --group-id sg-2f666d4d --protocol all --cidr #{my_ip}/32"
View keybase.md

Keybase proof

I hereby claim:

  • I am nhajratw on github.
  • I am nhajratw (https://keybase.io/nhajratw) on keybase.
  • I have a public key whose fingerprint is E853 899F 97FE 6231 D159 F204 41D6 BB63 207A C94C

To claim this, I am signing this object:

@nhajratw
nhajratw / app.coffee
Created Dec 11, 2013
angular-lineman-template app.js rewritten as app.coffee
View app.coffee
app = angular.module("app", ["ngResource", "ngRoute"]).run ($rootScope) ->
# adds some basic utilities to the $rootScope for debugging purposes
$rootScope.log = (thing) ->
console.log(thing)
$rootScope.alert = (thing) ->
alert(thing)
@nhajratw
nhajratw / application.js
Created Dec 11, 2013
Trying to define angular module using coffeescript per angular-lineman-template
View application.js
/* Exports an object that defines
* all of the configuration needed by the projects'
* depended-on grunt tasks.
*
* You can find the parent object in: node_modules/lineman/config/application.coffee
*/
module.exports = require(process.env['LINEMAN_MAIN']).config.extend('application', {
js: {
// if using coffeescript and your angular.module is defined in a .coffee file, files.coffee.generated comes first
@nhajratw
nhajratw / gist:6139826
Last active Dec 20, 2015
Performance of StringBuilder + Write
View gist:6139826
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.Writer;
import org.junit.Test;
public class SizeTest {
@Test
public void write_stringbuilder_to_file() throws Exception {
View gist:4715371
[/tmp/test] ➔ cat > one.txt
[/tmp/test] ➔ ls
one.txt
[/tmp/test] ➔ irb
irb(main):001:0> require 'fileutils'
=> true
irb(main):002:0> FileUtils.mv 'one.txt', 'two.txt'
=> 0
irb(main):003:0> exit
[/tmp/test] ➔ ls
@nhajratw
nhajratw / gist:4007724
Created Nov 3, 2012
Reversing an array
View gist:4007724
puts 'What are your favorite movies?'
movies = Array.new
3.times do |index|
print "#{index + 1}: "
movies << gets
end
puts 'Your reversed movies are:'
@nhajratw
nhajratw / gist:3918636
Created Oct 19, 2012
git log of last few days of checkins by role
View gist:3918636
productowner Fri Oct 19 10:24:28 2012
developer1 Fri Oct 19 10:07:17 2012
developer1 Thu Oct 18 23:26:51 2012
developer1 Thu Oct 18 21:41:53 2012
developer1 Thu Oct 18 19:29:35 2012
productowner Thu Oct 18 13:40:30 2012
developer2 Thu Oct 18 13:28:58 2012
developer2 Thu Oct 18 13:28:41 2012
developer2 Thu Oct 18 13:28:33 2012
developer2 Thu Oct 18 13:28:26 2012
@nhajratw
nhajratw / gist:3800175
Created Sep 28, 2012
Error upgrading vim
View gist:3800175
[~] ➔ brew doctor
Your system is raring to brew.
[~] ➔ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew upgrade
==> Upgrading vim
ln -s ../Cellar/vim/7.3.666/bin/xxd xxd
ln -s ../Cellar/vim/7.3.666/bin/vimtutor vimtutor
ln -s ../Cellar/vim/7.3.666/bin/vimdiff vimdiff
ln -s ../Cellar/vim/7.3.666/bin/vim vim
ln -s ../Cellar/vim/7.3.666/bin/view view
@nhajratw
nhajratw / gist:3783890
Created Sep 25, 2012
accessing functions??
View gist:3783890
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
var calculateCycleTime: function(acceptedDate, inProgressDate) {
var cycleTime = Math.round(Ext.Date.getElapsed(acceptedDate,inProgressDate) / 1000 / 60 / 60 / 24);
if (cycleTime === 0) cycleTime = 1;
return cycleTime;
You can’t perform that action at this time.