Skip to content

Instantly share code, notes, and snippets.

View jasonmcleod's full-sized avatar

Jason McLeod jasonmcleod

View GitHub Profile
function On_DoorUse(player, de) {
player.Message("Door Event Executed");
if(isMember(player)) {
if(getSquad(player) == getSquad(de.Entity.Owner)) {
player.Message("Door belongs to squad");
de.Open = true;
}
}
player.Message("Door Event Ended");
}
PlayerInventory.prototype.AddItem = function(item, qty) {
var self = this;
console.log(item)
var action = function(item, qty) {
var exists = _.findLessThan(self.Items,{Name:item},'UsesLeft',itemDB[item].stack);
if(exists && exists.UsesLeft < itemDB[item].stack && itemDB[item].stack!=1) {
exists.UsesLeft+=1;
if(qty-1>0) {
qty--;
action(item, qty);
PLUGIN.Title = "PlayersWebService"
PLUGIN.Description = "Publishes player list to a website"
local alternate = true
function PLUGIN:Init()
oxmin_mod = cs.findplugin("oxmin")
oxmin_mod:AddExternalOxminChatCommand(self, "online", {}, cmdList)
end
@jasonmcleod
jasonmcleod / map
Created August 7, 2013 19:51
array map
// create an empty array and hydrate it
var items = [];
data.map(function (item) {
if (item.kind === 'track') {
items.push({
id: item.id,
title: item.title,
provider: self.provider,
artist: item.user.username,
artwork: item.artwork_url,
@jasonmcleod
jasonmcleod / roger-test.html
Created July 9, 2013 17:53
Roger consumer
<script src='//code.jquery.com/jquery-1.10.2.min.js'></script>
<script src='//cdn.jsdelivr.net/jquery.cookie/1.3.1/jquery.cookie.js'></script>
<!-- .--- change to your roger server -->
<script src='http://localhost:4000/socket.io/socket.io.js'></script>
<script>
var socket;
$(function() { // .--- change to your roger server
socket = io.connect('http://localhost:4000');
@jasonmcleod
jasonmcleod / gist:5892912
Last active December 19, 2015 03:49
Circular JSON PFFFFFT
module.exports = function(self, options) {
this.bind = function(events) {
for(var e in events) {
(function(func) {
options.socket.on(func, function(data) { self[func](options, data) });
})(events[e])
}
}
}
@jasonmcleod
jasonmcleod / gist:5860529
Created June 25, 2013 17:36
Quote payload ideas
quotes = {
sourceA:{
AAPL:{bid:1, ask:1, last:3},
BAC: {bid:1, ask:1, last:3},
},
sourceB:{
AAPL:{bid:1, ask:1, last:3},
BAC: {bid:1, ask:1, last:3},
}
}
app.factory('trendingStocks', function($http) {
return {
fetch:function() {
var promise = $http.jsonp('https://api.stocktwits.com/api/2/streams/trending.json?callback=JSON_CALLBACK').then(function (response) {
var exp = /(\$[A-Z]{1,5})/;
var tweets = response.data.messages;
var trending = [];
for(var t in tweets) {
var symbols = exp.exec(tweets[t].body)
@jasonmcleod
jasonmcleod / cacheAudio
Created November 19, 2012 18:16
I needed to cache a bullet sound effect, and play it several times "on top of each other". To avoid a GET request on each shot, I cache 5 copies of it and cycle through them on each play()
sounds = {
'singleshot': '/assets/sounds/singleshot.mp3'
}
for(var s in sounds) {
var path = sounds[s];
sounds[s] = {
path:path,
clones:[],
channel:0,
@jasonmcleod
jasonmcleod / optionBind.js
Created February 9, 2011 20:57
Bind events to select > option. Even in IE
// IE won't recognize events bound to multi-select options (or any <option> tag for that matter)
// This is how I worked around that issue (for multi select , I'm afraid it fails on standard select menus.)
$("#radicalMultiSelectMenu option").live("click-option",function() {
// code I would have put in live("click") if IE wasn't a bastard.
// instead, I just created a custom event called click-option.
console.log(this);
});