Skip to content

Instantly share code, notes, and snippets.

View falkirks's full-sized avatar

noa falkirks

View GitHub Profile
@nikic
nikic / portAlternativeTags.php
Created September 12, 2014 17:41
Tool for porting alternative PHP tags to <?php, <?= and ?>
<?php
/*
* Note: This script will directly modify the .php files in the given directory.
* It is assumed that the code is under version control, so you can easily review
* the changes using `git diff` or similar.
*/
function usageError() {
die("Usage: php -d asp_tags=1 portAlternativeTags.php dir/\n");
@othiym23
othiym23 / npm-upgrade-bleeding.sh
Created September 20, 2014 19:36
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
@shoghicp
shoghicp / 3lines.php
Last active March 17, 2016 06:10
RC4 implementation in PHP, without run-time notices or errors. Outputs keystream directly. http://en.wikipedia.org/wiki/RC4
<?php
for($K='Key',$_=range($i=$j=0,$n=255);$i<=$n;$j+=$_[$i]+ord($K{$i%strlen($K)}),_($_[$j&=$n],$_[$i++]));
for($j=$i=0;++$i;$j+=$_[$i&=$n],_($_[$j&=$n],$_[$i]),printf('%x',$_[($_[$i]+$_[$j])&$n]));
function _(&$i,&$j){$i=$j+$i-($j=$i);}
@shoghicp
shoghicp / worldFixer.php
Last active July 4, 2018 12:16
This code will: Recreate lost signs, furnaces and chests, and remove invalid or corrupt tile entities from a world.
<?php
$world = $this->getServer()->getDefaultLevel();
$radius = 80;
$total = (($radius * 2) + 1) ** 2;
$count = 0;
for($chunkX = -$radius; $chunkX <= $radius; ++$chunkX){
for($chunkZ = -$radius; $chunkZ <= $radius; ++$chunkZ){
$chunk = $world->getChunk($chunkX, $chunkZ, false);
if($chunk instanceof \pocketmine\level\format\FullChunk and $chunk->isPopulated()){
$tiles = [];
@byteandahalf
byteandahalf / MCPE Windows 10.4 Symbolicate.idc
Last active August 29, 2015 14:11
Using this in IDA will add some symbols to the Minecraft PE Windows Phone executable
#include <idc.idc>
#define sym(addr, sym) symbolicateAddr(addr, sym)
static symbolicateAddr(addr, sym) {
MakeFunction(addr, BADADDR);
if(MakeNameEx(addr, sym, SN_NOWARN)) return;
auto i;
for(i = 0; i < 999; i++) if(MakeNameEx(addr, form("%s_%d", sym, i), SN_NOWARN)) return;
}
<?php
$world = $this->getServer()->getDefaultLevel();
$radius = 136;
$total = (($radius * 2) + 1) ** 2;
$count = 0;
$bList = clone \pocketmine\block\Block::$list;
$search = [];
#!/bin/bash
#PocketMine automatic analysis tool
echo "[*] PocketMine automatic analysis tool"
cat > ttyecho.c <<'TTYECHO'
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@byteandahalf
byteandahalf / demangle.txt
Last active March 23, 2020 17:11
How to demangle C++
Let's say we have this mangled symbol: _ZN5Class8functionEiifb10OtherClass
To demangle this, we start by removing the _Z (I'm not sure what this means)
N means that the following is the class name (There is no N is classless functions)
Next is the length of the class name (in this case 5), followed by the class name (Class)
Class::
Now we have the length of the function name (8 here) and then the function name (function)
Class::function
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
DEP_DIR="/usr/local/lib"
# Usage:
# Bash function libraries start with the line
# depends lib-1 lib-2
# And bash scripts start with the line
# source depends lib-1 lib-3
function depends {
for dependency in "$@"