Skip to content

Instantly share code, notes, and snippets.

@relict007
relict007 / term
Created September 16, 2013 12:59
urxvt client server script. Use this script as your terminal program, it launches urxvtc(client) and connects to the server (starting it if not running)
#!/bin/sh
urxvtc "$@"
if [ $? -eq 2 ]; then
urxvtd -q -o -f
urxvtc "$@"
fi
@relict007
relict007 / fan.sh
Last active December 23, 2015 04:29
Script for fan control on Dell laptops using i8k package. You need to have i8k support in kernel also. Just run this and it will control the fans automatically.
#!/bin/bash
#set -x
&> /dev/null
while [ 1 ]
do
temp=$(i8kctl temp)
#echo $temp
if [[ $temp -ge "0" && $temp -le "50" ]]
then
i8kfan -1 0
@relict007
relict007 / dpms_off.sh
Last active December 23, 2015 04:29
script to switch on/off the laptop LCD screen
#!/bin/bash
sudo vbetool dpms off
@relict007
relict007 / mergecursors.java
Last active January 4, 2016 08:19
Merge 2 adapters in Android
/*
* source: https://stackoverflow.com/questions/6754973/how-to-insert-extra-elements-into-a-simplecursoradapter-or-cursor-for-a-spinner/14622789#14622789
*/
MatrixCursor extras = new MatrixCursor(new String[] { "_id", "title" });
extras.addRow(new String[] { "-1", "New Template" });
extras.addRow(new String[] { "-2", "Empty Template" });
Cursor[] cursors = { extras, cursor };
Cursor extendedCursor = new MergeCursor(cursors);

The middle button over a titlebar kills the window

bindsym --release button2 kill

The middle button and a modifer over any part of the window kills the window

bindsym --whole-window $mod+button2 kill

The right button toggles floating

bindsym button3 floating toggle bindsym $mod+button3 floating toggle

Xft.autohint: 1
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintslight
Xft.hinting: 1
Xft.dpi:96
Xft.antialias: 1
Xft.rgba: rgb
public static String[] getStorageDirectories() {
// Final set of paths
final Set<String> rv = new HashSet<String>();
// Primary physical SD-CARD (not emulated)
final String rawExternalStorage = System.getenv("EXTERNAL_STORAGE");
// All Secondary SD-CARDs (all exclude primary) separated by ":"
final String rawSecondaryStoragesStr = System.getenv("SECONDARY_STORAGE");
// Primary emulated SD-CARD
final String rawEmulatedStorageTarget = System.getenv("EMULATED_STORAGE_TARGET");
if (TextUtils.isEmpty(rawEmulatedStorageTarget)) {
@relict007
relict007 / AutoValueImmutableListWithBuilder.java
Created March 15, 2017 11:49
AutoValue with builder and an immutable list
@AutoValue.Builder
public abstract static class Builder {
public abstract List<String> list();
public abstract Builder setList(List<String> list);
abstract ListContainer autoBuild();
public ListContainer build() {
setList(ImmutableList.copyOf(list()));

Keybase proof

I hereby claim:

  • I am saurabhlakhera on github.
  • I am saurabhlakhera (https://keybase.io/saurabhlakhera) on keybase.
  • I have a public key ASD3IW3dyUoR6DIwLVMSAn59GFcdo4Kef4X-KY2JYgWh6wo

To claim this, I am signing this object: