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 / bookmarklet.js
Last active March 9, 2023 01:01
youtube unblocker bookmarklet
javascript:(function(){var%20s=document.createElement('script');s.setAttribute('src','https://code.jquery.com/jquery-2.1.1.min.js');s.setAttribute('type','text/javascript');document.getElementsByTagName('head')[0].appendChild(s);$jq=jQuery.noConflict();$jq("a").each(function(i,el){var%20href=$jq(el).attr("href");var%20matches=href?href.match(/youtube.com\/watch\?.*?v=([a-zA-Z0-9_\-]+)/):null;if(matches){$jq(el).attr("href","https://www.youtube-nocookie.com/embed/"+matches[1]);}});$jq("iframe").each(function(i,el){var%20src=$jq(el).attr("src");var%20matches=src?src.match(/youtube.com\/embed\/([a-zA-Z0-9_\-]+)\??/):null;if(matches){$jq(el).attr("src","https://www.youtube-nocookie.com/embed/"+matches[1]);}});})();
#!/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 / WDTVLive.xml
Last active January 5, 2024 10:07 — forked from darth-veitcher/WDTVLive.xml
plex media server dlna profile for wdtv live
<Client name="WD TV Live HD Media Player">
<!-- Author: Plex Inc. -->
<!-- http://www.wdc.com/w...4779-705035.pdf -->
<!-- Model number tested: WDBAAN0000NBK -->
<!-- TODO - a few more limitations around codec profiles, which are high enough that they're probably not worth listing at present -->
<Identification>
<Header name="User-Agent" substring="alphanetworks" />
<Header name="User-Agent" substring="ALPHA Networks" />
</Identification>
<Settings>
@chetan
chetan / raspberrypi_fix_wifi.sh
Created March 18, 2015 16:14
Script to fix WIFI issues on the Raspberry Pi B+
#!/bin/bash
# The raspberrypi would occasionally lose WIFI.
# The fix is to reset the interface manually or reboot the device.
#
# Script should be run as root and run every 5 min:
# crontab:
# */5 * * * * /root/bin/fix_wifi.sh
PATH="/sbin:$PATH"
@chetan
chetan / all_runtime_dependencies.rb
Created November 21, 2014 20:24
List all runtime dependencies for the given gem
#!/usr/bin/env ruby
target = ARGV.shift.strip
class App
def initialize
@deps = []
end
def resolve(gem)

Keybase proof

I hereby claim:

  • I am chetan on github.
  • I am chetan (https://keybase.io/chetan) on keybase.
  • I have a public key whose fingerprint is 4B9C 048F 5423 B084 3143 68F1 0747 382F 0F4D C0DD

To claim this, I am signing this object:

@chetan
chetan / village_voice_bookmarklet.js
Created August 25, 2014 15:01
bookmarklet for single-page slideshows
// bookmarklet
javascript:var d = $("div.slide"), s = $($.grep($("script"), function(el) { return $(el).text().match(/VVMSlideShow/) })).text().replace(/\s+/g, "");s = s.substring(s.indexOf("photoData:")+10, s.indexOf("pointer:")-1);s = JSON.parse(s);_.each(s, function(v, i) {if (i === "1") return;d.append("<img src='" + v["Photo"] + "' />");});
// expanded version
var d = $("div.slide"),
s = $($.grep($("script"), function(el) { return $(el).text().match(/VVMSlideShow/) })).text().replace(/\s+/g, "");
s = s.substring(s.indexOf("photoData:")+10, s.indexOf("pointer:")-1);
s = JSON.parse(s);
_.each(s, function(v, i) {
if (i === "1") return;
@chetan
chetan / setjdk.sh
Created June 21, 2014 17:23
Handy helper for choosing JDK version on OS X
# via http://www.jayway.com/2014/01/15/how-to-switch-jdk-version-on-mac-os-x-maverick/
function setjdk() {
if [ $# -eq 0 ]; then
echo "ERROR: no jdk version given, choose from below"
echo "usage: setjdk 1.7"
echo
/usr/libexec/java_home --verbose
return
fi
user system total real allocations memsize
RABL Ultra Simple 2.660000 0.890000 3.550000 ( 3.557719) 106 8751
AMS Ultra Simple 0.280000 0.010000 0.290000 ( 0.285863) 26 650
Presenters Ultra Simple 0.170000 0.000000 0.170000 ( 0.174525) 24 650
ApiView Ultra Simple 0.190000 0.010000 0.200000 ( 0.196894) 12 842
-------------------------------------------------------------------------------------------------------------------
RABL Simple 14.240000 4.490000 18.730000 ( 18.813523) 590 53565
AMS Simple 1.280000 0.000000 1.280000 ( 1.290985) 105 2726
Presenters Simple 0.690000 0.010000 0.700000 ( 0.690873)
#!/usr/bin/env ruby
lines = STDIN.readlines.map{ |s| s.strip.downcase }
# lines = File.read("files.txt").split(/\n/).map{ |s| s.downcase }
files = {}
lines.each{ |s| files[s] = 1 }
lines.each do |s|
if s =~ /^(.*?)\.jn1$/ then
f = $1