Skip to content

Instantly share code, notes, and snippets.

@krmgns
krmgns / type-hint.php
Last active November 3, 2015 00:13
Spoofing PHP for default values with type-hint in functions/methods.
<?php
function foo(bool $x = true) { var_dump($x); }
?>
Fatal error: Default value for parameters with a class type hint can only be NULL in /var/www/... on line 2
<?php
// what the fuck? :)
define('None', '');
define('True', true);
@krmgns
krmgns / readme.md
Created November 13, 2015 22:32 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

@krmgns
krmgns / go.go
Last active November 16, 2015 00:54
Go tools.
import "fmt"
func Type(args ...interface{}) string {
return fmt.Sprintf("%T", args[0])
}
func Dump(args ...interface{}) {
fmt.Println(args...)
}
<!-- SQL.tmLanguage -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>sql</string>
<string>ddl</string>
<string>dml</string>
<!-- Old Github.tmTheme -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
======================================================================
Github
======================================================================
A Sublime Text 2 / Textmate theme.
Copyright (c) 2012 Dayle Rees.
Released under the MIT License <http://opensource.org/licenses/MIT>
<!-- JavaScript.tmLanguage -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>JavaScript Syntax: version 2.0</string>
<key>fileTypes</key>
<array>
<string>js</string>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>TODO:
• Try to improve parameters list syntax – scope numbers, ‘=’, ‘,’ and possibly be intelligent about entity ordering
• Is meta.function-call the correct scope? I've added it to my theme but by default it's not highlighted</string>
<key>fileTypes</key>
<array>
<?php
function trim_word_left($s, array $words) {
foreach ($words as $word) {
while (($p = mb_strpos($s, $word)) === 0) {
$s = mb_substr($s, $p + mb_strlen($word));
$s = trim($s);
}
}
return $s;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
Inspired GitHub Color Scheme for Sublime Text 3
Copyright 2015 Seth Lopez
Released under the MIT License <http://opensource.org/licenses/MIT>
https://github.com/sethlopezme/InspiredGitHub.tmtheme
-->
<!--
ed6a43 > this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
Inspired GitHub Color Scheme for Sublime Text 3
Copyright 2015 Seth Lopez
Released under the MIT License <http://opensource.org/licenses/MIT>
https://github.com/sethlopezme/InspiredGitHub.tmtheme
-->
<plist version="1.0">
<dict>