Skip to content

Instantly share code, notes, and snippets.

@nas
nas / example.ts
Last active December 30, 2022 20:22
// File: package.json
"dependencies": {
"@web3modal/ethereum": "^2.0.0-rc.1",
"@web3modal/react": "^2.0.0-rc.1",
"axios": "^1.1.3",
"ethers": "^5.7.2",
"next": "12.1.5",
"react": "18.0.0",
"react-dom": "18.0.0",
"swr": "^1.3.0",
@nas
nas / ssl_puma.sh
Last active August 29, 2015 14:22 — forked from tadast/ssl_puma.sh
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@nas
nas / mongo-import-export
Last active January 2, 2016 19:09
importing and exporting mongo db/collection in various formats
Binary
======
* Import database
mongorestore -h host:port -d experimental2 -u <user> -p <password> <input db directory>
* Export database
mongodump -h host:port -d experimental2 -u <user> -p <password> -o <output directory>
* Import collection
mongorestore -h host:port -d experimental2 -u <user> -p <password> <input .bson file>
* Export collection
mongodump -h host:port -d experimental2 -c <collection> -u <user> -p <password> -q <query else will export full collection> -o <output directory>
@nas
nas / gist:6773719
Last active July 23, 2022 19:01
tmux, vimrc, etc
==========
.tmux.conf
==========
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
set-option -g history-limit 10000
set-window-option -g xterm-keys
set-option -g mouse on
@nas
nas / gitio
Created July 28, 2013 08:19 — forked from defunkt/gitio
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
url = ARGV[0]
code = ARGV[1]
@nas
nas / Vim cheat sheet
Last active January 22, 2021 18:56
Some basic vim commands
Skipping some of the very basic commands, to use this cheat sheet you need atleast some vim knowledge.
; # repeat last search done using f
, # undo last search done using f
u # undo last change
ctrl+r # redo last change
:%s/t/r/g # replace all 't' by 'r'
:%s/t/r/gc # replace all 't' by 'r' with confirmation
~ # change case
gu # to lower case
@nas
nas / Rails4_with_ruby2
Last active December 10, 2015 17:28
boot up Rails 4 with Ruby 2
bundle 1.2.3 not compatible with ruby 2.0.0.preview2, do
gem install bundler --pre
to install bundler 1.3.0.pre.4
For any ssl issues
openssl needs to be >= 1.0.1
brew install openssl
brew link openssl
@nas
nas / lambda_to_proc
Created November 16, 2012 17:28
Simple script to replace lambda to proc in all files within a directory for rails named_scopes. Can be used for any other text replacement by just modifying the regex and substitution code
#!/usr/bin/ruby
directory = "app/models"
all_files = Dir.glob(File.join('app/models', '**', '*.rb'))
puts "Potentially modifying #{all_files.size}. Do you want to continue? [y/n]"
reply = gets
exit unless %w(y yes).include? reply.chomp.downcase
all_files.each do |filename|
@nas
nas / gist:3148888
Created July 20, 2012 05:37 — forked from igrigorik/gist:3148848
Convert any YouTube video into an audio file you can listen to on the go...
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > brew install ffprobe
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
@nas
nas / stress testing
Created July 4, 2012 12:38
Apache Bench
#! /usr/bin/ruby
raise "Provide the dir path" unless ARGV[0] =~ /[a-z]*/
to_dir = ARGV[0].strip
raise "Provide the dir path" if to_dir.nil?
site = 'http://url'
print "Processing home page ... "