Skip to content

Instantly share code, notes, and snippets.

@asuraphel
asuraphel / lock.c
Created December 5, 2012 16:22
Athena locking code
/* lock.c --- handling the password dialog for locking-mode.
* xscreensaver, Copyright (c) 1993-2011 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
/* See LICENSE file for license details. */
#define _XOPEN_SOURCE 500
#if HAVE_SHADOW_H
#include <shadow.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <pwd.h>
#include <stdarg.h>
@asuraphel
asuraphel / gist:6696193
Created September 25, 2013 07:21
Easily install vim plugins from a source control checkout (e.g. Github)
# Easily install vim plugins from a source control checkout (e.g. Github)
#
# alias vim-install=rake -f ~/.vim/rakefile-vim-install
# vim-install
# vim-install uninstall
require 'ftools'
require 'fileutils'
task :default => :install
@asuraphel
asuraphel / gist:6974630
Created October 14, 2013 12:08
Select by form builder
f.select :channel_type, options_for_select( [['Message', 'Message'],['Auto-respond', 'Respond'],['API', 'API']]), class: "form-control"
@asuraphel
asuraphel / gist:7083301
Created October 21, 2013 12:45
/etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME=/usr/local/java/jdk1.7.0-openjdk-amd64
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.7.0-openjdk-amd64
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
@asuraphel
asuraphel / gist:7083553
Created October 21, 2013 13:05
~/.bash_rc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
JAVA_HOME=/usr/local/java/jdk1.7.0-openjdk-amd64
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jre1.7.0-openjdk-amd64
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
@asuraphel
asuraphel / gist:7155026
Created October 25, 2013 13:51
The semi-colon before the last one
addToDo.setOnKeyListener( new View.OnKeyListener() {
public boolean onKey(View V, int keyCode, KeyEvent event) {
if( event.getAction() == KeyEvent.ACTION_DOWN ) {
if( (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) || (keyCode == KeyEvent.KEYCODE_ENTER)) {
String newItem = addToDo.getText().toString();
onNewItemAddedListener.onNewItemAdded(newItem);
addToDo.setText("");
return true;
}
@asuraphel
asuraphel / gist:7155131
Created October 25, 2013 13:59
Anon inner classes
//: innerclasses/Parcel7.java
// Returning an instance of an anonymous inner class.
public class Parcel7 {
public Contents contents() {
return new Contents() { // Insert a class definition
private int i = 11;
public int value() { return i; }
}; // Semicolon required in this case
}
public static void main(String[] args) {
@asuraphel
asuraphel / gist:7320074
Created November 5, 2013 14:44
my Grails controller
package qotd
class QuoteController {
def index() {
redirect( action: "home" )
}
def home() {
@asuraphel
asuraphel / gist:7370028
Created November 8, 2013 11:59
Domain class from Grails in Action book
package com.grailsinaction
class User {
String userId
String password
String homepage
Date dateCreated
static constraints = {