Skip to content

Instantly share code, notes, and snippets.

View chetan's full-sized avatar
🙌
like my work? sponsor me!

Chetan Sarva chetan

🙌
like my work? sponsor me!
View GitHub Profile
@chetan
chetan / editor.js
Created December 27, 2021 22:03 — forked from image72/editor.js
simple react sandbox playground
import {EditorState, EditorView, basicSetup} from "@codemirror/basic-setup"
import {javascript} from "@codemirror/lang-javascript"
const jscode=`
// Note:
// 1. Use React.something instead of importing something
// 2. Container id is 'app'
function Counter({initialCount}) {
@chetan
chetan / db.rake
Last active July 12, 2022 19:18 — forked from e12e/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6
#
# This is the code from the comment:
# https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90#gistcomment-2275324
# Made into a fork/separate gist for easier download, with redundant shell-script removed.
#
#
# Usage:
@chetan
chetan / Makefile
Last active June 17, 2022 15:20
Generate changelog.md from github releases
# Update CHANGELOG.md with latest release
update-changelog:
echo -e "# Changelog\n" >> temp.md
rel=$$(gh release list | head -n 1 | awk '{print $$1}'); \
echo "## $$rel" >> temp.md; \
echo "" >> temp.md; \
gh release view --json body $$rel | \
jq --raw-output '.body' | \
grep -v '^## Changelog' | \
sed -e 's/^#/##/g' >> temp.md
#!/bin/bash
# Copied from http://willwarren.com/2014/07/03/roll-dynamic-dns-service-using-amazon-route53/
# Externalizing the zone ID and CNAME
if [ -z "$1" ]
then
echo "The first argument needs to be the Hosted Zone ID, i.e. BJBK35SKMM9OE"
exit 1
fi
@chetan
chetan / tomcat.initd.sh
Last active January 20, 2022 13:45 — forked from valotas/tomcat.sh
tomcat init.d script
#!/bin/bash
#
# tomcat This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
@chetan
chetan / bi
Created November 24, 2021 18:13
Quickly search for homebrew formula or casks and display info via fzf
#!/usr/bin/env ruby
# bi
# Quickly fetch and display info for the given homebrew formula or cask
#
# perf:
# brew info nginx -> 0m1.742s
# bi nginx -> 0m0.166s
#
# Works well with fzf (via brew.fzf)
@chetan
chetan / cleanup_temp_files.bat
Created January 11, 2014 03:43
Handy script for cleaning up old temporary files on windows. ReportQueue (from error reporting) gets especially large...
@echo off
IF EXIST c:\windows\temp\ (
forfiles /p "C:\Windows\Temp" /s /m *.* /D -7 /C "cmd /c del /Q @path"
)
IF EXIST "C:\Users\" (
for /D %%x in ("C:\Users\*") do (
forfiles /p "%%x\AppData\Local\Temp" /s /m *.* /D -7 /C "cmd /c del /Q @path"
forfiles /p "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files" /s /m *.* /D -7 /C "cmd /c del /Q @path"
@chetan
chetan / findHidden.js
Last active May 23, 2020 21:01
jQuery func to find out why an element is hidden
function found(el, css) {
console.log('Found candidate(s):', el);
console.log('css:', css);
}
function findHidden(sel) {
const transparent = 'rgba(0,0,0,0)';
const el = $(sel);
if (el.length === 0) {
console.log('giving up, no more els');
#!/usr/bin/ruby
#
# adduser - Unix-like adduser script. Prompts for parameters and uses dscl internally to create
# new NetInfo users and groups.
#
# Chetan Sarva <csarva@pixelcop.net>
def next_user_id(start = 700)
ids = `dscl . -list /Users UniqueID`.split("\n").map{|s| s =~ /(\d+)$/; $1 }.sort.uniq
n = start
@chetan
chetan / vertica5-installer-ubuntu10.04.patch
Created November 30, 2011 19:00
patch to enable vertica5 to be installed on ubuntu 10.04 (lucid)
--- /opt/vertica/oss/python/lib/python2.7/site-packages/vertica/network/SystemProfileFactory.py.orig 2011-09-15 14:28:14.000000000 -0400
+++ /opt/vertica/oss/python/lib/python2.7/site-packages/vertica/network/SystemProfileFactory.py 2011-09-15 14:29:51.000000000 -0400
@@ -142,8 +142,14 @@
if (res[0] == '0'):
opsys = DBinclude.OS_DEBIAN
return opsys, host
+
+ (status, res) = ssh.execute("grep \"squeeze\" /etc/debian_version", hide=True)
+ if (res[0] == '0'):
+ opsys = DBinclude.OS_DEBIAN