Skip to content

Instantly share code, notes, and snippets.

@mtabini
mtabini / gist:1178403
Created August 29, 2011 13:35
PNG representation of NSImage
//
// GRAppDelegate.m
// Testme
//
// Created by Marco Tabini on 11-08-29.
// Copyright (c) 2011 Marco Tabini. All rights reserved.
//
#import "GRAppDelegate.h"
@webdesserts
webdesserts / Gulpfile.js
Last active April 3, 2023 08:16
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@sindresorhus
sindresorhus / post-merge
Last active July 25, 2024 06:53
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active November 27, 2024 13:36
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@zorgiepoo
zorgiepoo / gist:5f769893ad2a7f58a747
Last active February 11, 2018 16:12
Game speed hack prototype; still WIP
#Game Speed Hack
#Increase x86-64 game by 2x by overriding mach_absolute_time
#May not work on games that call gettimeofday or something else instead
#May not work on games that don't call a time function at all (these areee badddd)
#May also not work if the function is referenced in more than one executable image (eg, local library)
#This is not very robust
from bitslicer import VirtualMemoryError, DebuggerError
import vmprot
SPEED_MULTIPLIER = 2.0
@JonathanPorta
JonathanPorta / gist:2bdf39d59c9bf75e61f9
Last active November 21, 2017 20:47
How to figure out if a steam app has an update available
Great Example: https://github.com/dgibbs64/linuxgsm/blob/b8312d1160271e4a36a0edada3fa11ba9b5e2cdb/functions/fn_update_check#L109-L127
Steamcmd: steamcmd.exe +login anonymous +app_info_print 258550 +quit
Some potentially helpful thingys:
https://github.com/Philipp15b/go-steamapi
https://github.com/Philipp15b/go-steam
https://steamdb.info/app/740/history/
https://steamdb.info/api/GetRawDepots/?appid=740
@gyaresu
gyaresu / gootfet-bash.txt
Last active May 17, 2022 20:03
GoodFET failure
====== Inexplicably it just worked... I think. Those ff's are fairly ominous =====================
pentoo ~ # goodfet.bsl --dumpinfo > info.txt
Use -h for help
Use --fromweb to upgrade a GoodFET.
MSP430 Bootstrap Loader Version: 1.39-goodfet-8
Invoking BSL...
Transmit default password ...
Current bootstrap loader version: 2.13 (Device ID: f26f)
pentoo ~ # cat info.txt
@brianmcallister
brianmcallister / vwap.js
Last active August 25, 2021 16:55
VWAP (Volume Weighted Average Price) function.
/**
* Calculate VWAP (volume weighted average price) for a list of bids.
*
* @param {number} total - Total shares bought.
* @param {Array<number, number>} positions - Tuples of position data. The first
* index is the amount of shares, the
* second index is the price of the
* shares.
*
* @example
@tiagosiebler
tiagosiebler / multi-ipn.php
Created February 2, 2017 20:25 — forked from anointed/multi-ipn.php
Paypal multiple IPN's
<?php
/*
* This is a PayPal IPN (Instant Payment Notification) broadcaster
* Since PayPal does not provide any straightforward way to add
* multiple IPN listeners we'll have to create a central IPN
* listener that will broadcast (or filter and dispatch) Instant
* Payment Notifications to different destinations (IPN listeners)
*
* http://codeseekah.com/2012/02/11/how-to-setup-multiple-ipn-receivers-in-paypal/
*
package global;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.awt.AWTException;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Rectangle;