Skip to content

Instantly share code, notes, and snippets.

View IQAndreas's full-sized avatar

Andreas Renberg IQAndreas

View GitHub Profile
@IQAndreas
IQAndreas / sshd_config
Created August 7, 2015 16:28
See [_SuperUser: Block Access from outside of LAN_](http://superuser.com/q/952192/114760)
# This is the setting that is ONLY available if you are SSHing from the LAN (allow the listed users)
Match Address 192.168.0.*
AllowUsers git adam bob cliff dave
# This displays a message if the user NOT 'git' AND connecting from outside of the LAN
# Note, the extra *, is due to this bug: http://superuser.com/q/952235/114760
Match User *,!git Address *,!192.168.0.*
ForceCommand /bin/echo "Sorry, you are only allowed to connect to this server via git."
@IQAndreas
IQAndreas / gist:cbe8da2642ed6dc5526f
Last active August 29, 2015 14:21
Size of partitions on an Android file system. See http://android.stackexchange.com/q/109108/79207
/5CAC-A061/recover$ du -ch mmcblk0p*
1.0M mmcblk0p10.dd
1.0M mmcblk0p11.dd
8.6M mmcblk0p12.dd
4.0M mmcblk0p13.dd
4.0M mmcblk0p14.dd
1.0M mmcblk0p15.dd
6.8M mmcblk0p16.dd
256K mmcblk0p17.dd
1.0M mmcblk0p18.dd
function works() {
function foo() {
console.log('ok');
};
var works_ref;
works_ref = foo;
console.log('works ' + works_ref);
}
@IQAndreas
IQAndreas / gist:f250db7356e0c259d45b
Last active August 29, 2015 14:17
"When your hammer is JavaScript, everything begins to look like a thumb" ~ @mariofusco ---- Meanwhile in Java:
World.java:42: error: method 'hit' in class 'Hammer' cannot be applied to given types;
hammer.hit(target);
^
required: Nail
found: Thumb
reason: actual argument 'Thumb' cannot be converted to 'Nail' by method invocation conversion

Excerpt from Concepts of Programming Languages Ninth Edition by Professor Robert W. Sebesta

Many programmers when given a choice of languages for a new project, continue to use the language with which they are most familiar, even if it is poorly suited to the project.

If these programmers were familiar with a wider range of languages, they would be better able to choose the language that includes the features that best address the characteristics of the problem at hand.

var http = require('http');
var countdown = [
"America has given us the monkey, and Mann Co. has provided the fuel. Let's put those two together and make history!",
"Attention! One minute left in the mission, one minute left in the mission.",
"The bomb is nearing a checkpoint.",
"We have recieved additional time.",
"Thirty seconds left.",
"Heavy: Why is no one pushing cart?",
"Twenty seconds remaining.",
@IQAndreas
IQAndreas / not-a-shell.coffee
Created December 16, 2014 00:57
Hubot script which yells at users who try to treat [`ssh-chat`](https://github.com/shazow/ssh-chat) as if it were a shell
// Yells at users for thinking this is an SSH shell
// Responds to the following commands (case sensitive, obviously):
// ls
// rm
// cat
module.exports = (robot) ->
robot.respond /([^:]+): (ls|rm|cat)/, (msg) ->
user = msg.match[1]
msg.send("Damn it, #{user}. This is a chat room, not a shell!")
@IQAndreas
IQAndreas / exit.coffee
Created December 16, 2014 00:53
Hubot script to help the user if they tried to exit the chat room using the wrong command.
// Alerts the user if they typed one of the following (with our without a preceeding backslash)
// exit
// quit
module.exports = (robot) ->
robot.respond /([^:]+): \\?(exit|quit)/i, (msg) ->
user = msg.match[1]
msg.send("#{user}: Try /exit")
@IQAndreas
IQAndreas / gist:08cd95ac2c497bdeda56
Created November 28, 2014 04:12
How to flip a 2x3 matrix
[ a b ]
[ c d ]
[ e f ]
[ e c a ]
(╯°□°)╯︵ [ f d b ]
@IQAndreas
IQAndreas / static-redeclare.php
Created August 21, 2014 14:17
Unable to create a PHP function with the same name as a static function. Results in the error message listed below. See: http://stackoverflow.com/q/25428887/617937
<pre><?php
class Module
{
// ---- Static methods ----
private static $config = array();
public static function get_config($module_name, $field)
{
if (!isset(Module::$config[$module_name]))