Navigation Menu

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 / 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 / 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 / Automate git pulling
Created July 3, 2010 05:16
Automate git pulling
#!/usr/local/bin/ruby -swI .
#
# AUTOMATE UPDATING ALL PROJECTS
#
# Problem: going to each project and then pulling changes.
# Solution: Automate git pulling for all my projects
#
# 1. Create a pull_projects file and add the code from this gist
# 2. Move the file into a directory that is in your path, i.e. $PATH
# 3. Make the file executable, eg. chmod +x /usr/local/bin/pull_projects
@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 / 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 / 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 / gbgrep
Created May 20, 2011 18:19
git blame with grep
#!/usr/local/bin/ruby
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}`
puts "\n-----------------------------------------------------------"
puts "GREP RESULT"
puts '-----------------------------------------------------------'
puts grep
files = grep.scan /.*\:\d+/
@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)