Skip to content

Instantly share code, notes, and snippets.

@rahulsom
rahulsom / nettest.sh
Created June 25, 2012 02:55
MacbookPro5,1 has a serious problem with it's wireless. Apple will not acknowledge it, but here's a fix
#!/bin/sh
#
# Tests network status and resets Airport if required
#
usage() {
cat << EOF
Usage: $0 options
-h HOST host to ping
-s <ON|OFF> say out loud: on or off default: OFF
/*
This is my solution to https://www.youtube.com/watch?v=LYKn0yUTIU4
Languages are hard. General assumptions:
1. What qualifies as a letter is hard to explain in some languages like most indic languages.
My definition of what comprises a letter is what takes up on character in UTF encoding.
2. Same applies to chinese. In Chinese there's symbols for the every letter that are unicode symbols.
That makes chinese almost similar to the decimal number system.
Q1. What's the smallest number to form an english sequence of 7?
7: [323 (three hundred twenty-three), 23 (twenty-three), 11 (eleven), 6 (six), 3 (three), 5 (five), 4 (four)]
@rahulsom
rahulsom / Foo.groovy
Created July 19, 2012 16:31
Reloading Scripts in groovy, Erlang style
public class ReloadingScript {
/**
* The Class of the script
*/
Class clazz
/**
* Runs the script in a Erlang-ish loop
*
@rahulsom
rahulsom / Ele.groovy
Last active November 29, 2016 13:58
Mahout with Groovy - the faster way
@Grab(group = 'org.apache.mahout', module = 'mahout-core', version = '0.9')
import org.apache.mahout.cf.taste.impl.common.FastByIDMap
import org.apache.mahout.cf.taste.impl.common.FastIDSet
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel
import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender
import org.apache.mahout.cf.taste.impl.similarity.TanimotoCoefficientSimilarity
def mlDir = '/Users/rahulsomasunderam/Downloads/ml-100k'
def f = new File("$mlDir/u.data")
@rahulsom
rahulsom / restart-audio-daemon.sh
Created December 10, 2016 19:09
Restart Audio Daemon
# All this comes from https://twitter.com/viktorklang/status/807629003385237504
function restart_audio() {
command sudo killall coreaudiod && \
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist && \
sudo launchctl load /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist || \
return
echo 'Audio daemon restarted'
}
@rahulsom
rahulsom / demo.adoc
Created January 29, 2018 05:08
Asciidoctor source with attributes subs bug demo

Demo

This works, but is not ideal

build.gradle.kts
buildscript {
    dependencies {
@rahulsom
rahulsom / .gitignore
Last active April 5, 2018 21:49
Shorter Pretty Printed JSON
.idea
out/
.idea_modules/
*.iml
@rahulsom
rahulsom / Directions.groovy
Created May 26, 2011 03:55
Demo to use Groovy, Grape, and Google Maps API to go from coast to coast
@groovy.lang.Grapes([
@groovy.lang.Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC2')
])
import groovyx.net.http.*
def http = new HTTPBuilder('https://maps.googleapis.com/maps/api/directions/')
http.get(path: 'json',
query: [
@rahulsom
rahulsom / fs.css
Created February 12, 2016 23:21
CSS theme for Jenkins Delivery Pipeline to play well with Neo
body {
font-family: sans-serif;
background: #000000;
color: #fefefe;
font-size: 14px;
}
div.pipeline-loading-icon {
content: url("dark-load.gif");
}
@rahulsom
rahulsom / jenkins.jelly
Last active April 3, 2019 20:13
Jelly Template for Jenkins.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- If you delete this tag, the sky will fall on your head -->
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ZURBemails</title>
<style data-inline="true">