Skip to content

Instantly share code, notes, and snippets.

View cengiz-io's full-sized avatar

Cengiz Can cengiz-io

View GitHub Profile
@randrews
randrews / hoc1.lua
Created May 29, 2015 23:32
Toy calculator in Lua, version 1
function eval(num1, operator, num2)
if operator == '+' then
return num1 + num2
elseif operator == '-' then
return num1 - num2
elseif operator == '*' then
return num1 * num2
elseif operator == '/' then
return num1 / num2
else
@katspaugh
katspaugh / README.md
Last active August 29, 2015 14:20
Show the beginning of defun at point

This is an attempt to replicate a feature found in WebStorm:

When you are in the end of a block, and the beginning of the block is outside the viewport, it shows you the beginning in a nice overlay.

In Emacs we can show the beginning of function definition at point in the header line.

@mgoral
mgoral / pydetect
Created October 23, 2014 05:52
xrandr wrapper
#!/usr/bin/env python
import optparse
from subprocess import Popen, PIPE
import time
def prepare_options():
"""Define optparse options."""
optp = optparse.OptionParser(
usage = 'Usage: %prog OUT1 [OUT2 OUT3...]\n\tOUT[n] are devices taken from left to right.',
@bradrydzewski
bradrydzewski / generate_docker_cert.sh
Last active February 14, 2025 07:04
Generate trusted CA certificates for running Docker with HTTPS
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
# See http://docs.docker.com/articles/https/
#
# To start the Docker Daemon:
#
# sudo docker -d \
anonymous
anonymous / sigh.
Created April 20, 2014 22:32
if (handler.dom[0] && handler.dom[0].children[1] && handler.dom[0].children[1].children[0] && handler.dom[0].children[1].children[0].children[4] && handler.dom[0].children[1].children[0].children[4].children[1] && handler.dom[0].children[1].children[0].children[4].children[1].children[1] && handler.dom[0].children[1].children[0].children[4].children[1].children[1].children[0] && handler.dom[0].children[1].children[0].children[4].children[1].children[1].children[0].children[0] && handler.dom[0].children[1].children[0].children[4].children[1].children[1].children[0].children[0].children[0]){
var string = handler.dom[0].children[1].children[0].children[4].children[1].children[1].children[0].children[0].children[0].data;
var index = string.search(/\(.*\)/);
var listeners = parseInt(string.substr(index+1, 2),10);
if (listeners > 0){
listeners -= 1; // one listener is this application itself
}
self.streamListeners = listeners;
callback(listeners, se
@Keith-S-Thompson
Keith-S-Thompson / README.md
Last active March 22, 2023 03:06
Discussion of korn.c, 1987 IOCCC entry, mentioned in http://stackoverflow.com/a/19214007/827263

korn.c is the "Best One Liner" winner of the 1987 International Obfuscated C Code Contest, by David Korn (yes, the author of the Korn Shell).

korn.hint, as the name implies, offers some hints.

A commenter on Stack Overflow asked for some clarification. I didn't want to post spoilers on the site, so I'm posting them here instead. If you haven't already (and if you're familiar with the rules of C) I encourage you to study the program for a while first.

=====

Here's the code:

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@ihabunek
ihabunek / gist:3957832
Created October 26, 2012 09:27
Install Apache log4php using Composer

Install Apache log4php using Composer

First, install Composer if you don't yet have it:

php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

Create a composer.json file with the following content:

{

@clstokes
clstokes / tomcat7
Created September 25, 2012 21:06
Enable JMX in Tomcat 7 on Ubuntu
#
# Since I have to look this up every time...
#
# Add the following in /etc/default/tomcat7
#
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.port=9991"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote.ssl=false"
@Dinnerbone
Dinnerbone / gist:3736487
Created September 17, 2012 09:49
New Minecraft target selector syntax!

Syntax

All target selectors start with @. The following character is the selector type. For example, @p means 'closest player'.

Target selectors may have additional, optional arguments. You can specify these in [ ], using the syntax a=0. For example, @p[a=0,b=5,c=-500].

There is a special short syntax for just specifying x, y, z and r arguments; simply list their values separated by a comma, without x=. For example: @p[100,64,-100,5] for 5 range, x=100, y=64 and z=-100. Each of these are optional and skippable by leaving them empty. For example, to just specify y coordinate: @p[,64].

Global Arguments:

  • x - X coordinate for search center. Default is senders coordinate, or 0.
  • y - Y coordinate for search center. Default is senders coordinate, or 0.