Skip to content

Instantly share code, notes, and snippets.

Avatar

JJ Asghar jjasghar

View GitHub Profile
@jjasghar
jjasghar / breaktime.el
Last active Aug 26, 2015 — forked from camdez/breaktime.el
/u/joeheyming's Emacs break timer (modified)
View breaktime.el
;;; See: https://www.reddit.com/r/emacs/comments/3icpo7/take_a_break_every_3_hours/
(defvar breaktime-timer nil
"Holds the running break timer (if any).")
(defvar breaktime-interval (* 3 60 60)
"How often to take a break, in seconds.")
(defun breaktime--take-a-break ()
(interactive)
(switch-to-buffer (get-buffer-create "*breaktime*"))
(let ((inhibit-read-only t))
@jjasghar
jjasghar / chef-campfire-workaround.md
Created Jan 29, 2014
chef-campfire-handler gem work around
View chef-campfire-workaround.md
cookbook_file "/tmp/tinder-1.9.3.gem" do
  owner "root"
  group "root"
  mode "0644"
  source "tinder-1.9.3.gem"
end

gem_package "tinder" do
  gem_binary("/opt/chef/embedded/bin/gem")
View ec_node_fixer.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'chef/knife'
Chef::Config.from_file(File.join(Chef::Knife.chef_config_dir, 'knife.rb'))
rest = Chef::REST.new(Chef::Config[:chef_server_url])
Chef::Node.list.each do |node|
%w{read update delete grant}.each do |perm|
View ruby tutorial.md

Managing rubies and rvm on OSX

Get rid of rvm

Unistall rvm ( if there exists one )

rm -rf ~/.rvm

Fresh install rvm

View campfire_test stacktrace
[root@testing-sensu01 ~]# /opt/sensu/embedded/bin/ruby campfire_test.rb
/opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::Error::ConnectionFailed)
from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:917:in `block in connect'
from /opt/sensu/embedded/lib/ruby/2.0.0/timeout.rb:51:in `timeout'
from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:917:in `connect'
from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:861:in `do_start'
from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:850:in `start'
from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1366:in `request'
from /opt/sensu/embedded/lib/ruby/2.0.0/net/http.rb:1125:in `get'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/faraday-0.8.7/lib/faraday/adapter/net_http.rb:73:in `perform_request'
View keybase.md

Keybase proof

I hereby claim:

  • I am jjasghar on github.
  • I am jjasghar (https://keybase.io/jjasghar) on keybase.
  • I have a public key whose fingerprint is AF70 4670 6510 2BED FE2A 927B DC93 CDB0 B4D4 6649

To claim this, I am signing this object:

View chef.rake
namespace :roles do
desc 'dump roles defined in the Ruby DSL to json'
task :dump do
destination_dir = File.join(TOPDIR, '.chef', 'chef_server_backup')
files_paths = Dir["#{TOPDIR}/roles/*.rb"]
files_paths.each do |filename|
role_name = File.basename(filename, '.rb')
role = Chef::Role.new
View evills
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'http://github.com/cburgmer/upsidedown'
@jjasghar
jjasghar / console.rb
Created Apr 25, 2014
update a password via rails console
View console.rb
irb(main):001:0> u = User.find_by_id(1)
User Load (3.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
=> #<User id: 1, name: "JJ Asghar", email: "jjasghar@gmail.com", created_at: "2014-04-18 17:46:48", updated_at: "2014-04-25 23:21:10", password_digest: "$2a$10$or/wJw1I8Wpf0lXNbtawveoQXETGJbUkv/VwXQXzn92r...", remember_token: "uUJTExCyt4mpAOpQWd4PMA">
irb(main):002:0> u
=> #<User id: 1, name: "JJ Asghar", email: "jjasghar@gmail.com", created_at: "2014-04-18 17:46:48", updated_at: "2014-04-25 23:21:10", password_digest: "$2a$10$or/wJw1I8Wpf0lXNbtawveoQXETGJbUkv/VwXQXzn92r...", remember_token: "uUJTExCyt4mpAOpQWd4PMA">
irb(main):003:0> u.password = "a_stupid_pa$$word"
=> "_stupid_pa$$word"
irb(main):004:0> u.password_confirmation = "a_stupid_pa$$word"
=> "_stupid_pa$$word"
irb(main):005:0> u.save
View readme.md

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser