This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this code came from Fancyham - http://fancyham.com/tips/OS_X_toggle_display_rotation_applescript.html | |
-- Now works with Mountain Lion 10.8 | |
-- Rotate Display on machines | |
-- This code is offered without any liability implied or explicit. | |
-- Use it at your own risk. | |
-- Copyright 2005, 2006 Conrad Albrecht-Buehler | |
-- Modifications for portrait/landscape only May 2006 Bryan Wu to support toggling between only two modes - landscape and portrait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See my answer to Stack Overflow: Maximum java heap size of a 32-bit JVM on a 64-bit host | |
// http://stackoverflow.com/questions/1434779/maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os/7019624#7019624 | |
// and my blog: http://milosophical.me/blog/2007/03/04/32-bit-windows-and-jvm-virtual-memory-limit.html | |
public class MaxMemory { | |
public static void main(String[] args) { | |
Runtime rt = Runtime.getRuntime(); | |
long totalMem = rt.totalMemory(); | |
long maxMem = rt.maxMemory(); | |
long freeMem = rt.freeMemory(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- I have no idea where this came from :( A work colleage showed me it. | |
WITH RECURSIVE | |
x(i) | |
AS ( | |
VALUES(0) | |
UNION ALL | |
SELECT i + 1 FROM x WHERE i < 101 | |
), | |
Z(Ix, Iy, Cx, Cy, X, Y, I) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Muhammad Ahmad Tirmazi | |
# Date: January 4, 2014 | |
from decimal import * | |
import math | |
class PiCalculator(): #Calculates Pi | |
def __init__(self, prec): | |
getcontext().prec = prec # the precision | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Calculate digits of pi. This module can be run interactively with | |
python pidigits.py | |
""" | |
__docformat__ = 'plaintext' | |
import sys | |
import math |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# keep essential system daemons safe from the OOM killer | |
*/1 * * * * root pgrep -f "/sbin/sshd" | while read PID; do echo -17 > /proc/$PID/oom_adj; done | |
*/1 * * * * root pgrep -f "/sbin/rsyslogd" | while read PID; do echo -17 > /proc/$PID/oom_adj; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* insult generator */ | |
var BodyParts = ["face", "nose", "hair"]; | |
var Adjectives = ["smelly","boring","stupid","elderberry"]; | |
var Words = ["fly", "marmot", "stick", "monkey", "rat", "smeg"]; | |
var pickRandom = function(pickings) { | |
return pickings[Math.floor(Math.random() * pickings.length)]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Now works with Mountain Lion 10.8 | |
-- Rotate Display on machines | |
-- This code is offered without any liability implied or explicit. | |
-- Use it at your own risk. | |
-- Copyright 2005, 2006 Conrad Albrecht-Buehler | |
-- Modifications for portrait/landscape only May 2006 Bryan Wu to support toggling between only two modes - landscape and portrait | |
-- NOTE: UI Scripting must be enabled for this to work! Confirm that | |
-- "Enable access for assistive devices" is checked in the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 REM This is for Amstrad CPC Locomotive BASIC | |
10 CLS | |
20 WHILE 1>0 | |
30 GRAPHICS PEN 15*RND | |
40 MOVE 640*RND,400*RND | |
50 DRAW 640*RND,400*RND | |
60 WEND |