Skip to content

Instantly share code, notes, and snippets.

@2tunnels
2tunnels / script.js
Created March 9, 2018 15:25
Screeps
// Spawn harvester
Game.spawns.Spawn_1.spawnCreep([WORK, CARRY, MOVE], `Harvester_${Game.time}`, {memory: {role: 'harvester'}});
// Loop has issues.
// If spawn is full, harvester will stop.
module.exports.loop = function () {
const creep1 = Game.creeps['Harvester{Game.time}'];
if (creep1.carry[RESOURCE_ENERGY] === creep1.carryCapacity) {
console.log(`${creep1.name} is full`);
@2tunnels
2tunnels / console.js
Created August 5, 2015 21:32
Google URLs
var links = document.querySelectorAll('.srg .g h3 a'); var urls = []; [].forEach.call(links, function(link) { urls.push(link.href.indexOf('google') === -1 ? link.href : link.getAttribute('data-href')) }); prompt('URL', urls.join('\n'));
Ning inurl:profiles/blog/list -inurl:ning.com
@2tunnels
2tunnels / game.lua
Created March 20, 2014 16:45
Corona SDK physics.removeBody() cannot be called ... during collision event.
local storyboard = require( "storyboard" )
local physics = require( "physics" )
local scene = storyboard.newScene( "game" )
local box
local ground
function scene:createScene( event )
local group = self.view
@2tunnels
2tunnels / install.sh
Last active December 21, 2015 23:29
Install PHP 5.5 on Ubuntu 12.04
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5-cli php5-common php5-fpm
@2tunnels
2tunnels / gist:6283881
Created August 20, 2013 16:35
Vagrant issue: The following SSH command responded with a non-zero exit status.
Error message:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /vagrant /vagrant
Stdout from the command:
{
"font_size": 11,
"translate_tabs_to_spaces": true,
"highlight_line": true,
"line_padding_top": 4,
"line_padding_bottom": 4,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true
}
@2tunnels
2tunnels / index.php
Created April 25, 2013 03:08
Get age from birth date
<?php
$timezone = new DateTimeZone('Europe/Brussels');
$age = DateTime::createFromFormat('Y-m-d H:i:s', '1990-09-12 00:00:00', $timezone)
->diff(new DateTime('now', $timezone))
->y;
return $age;