Skip to content

Instantly share code, notes, and snippets.

View ximex's full-sized avatar

Thomas Rupprecht ximex

View GitHub Profile
@ximex
ximex / filter-speedtest.js
Created June 12, 2021 16:32
Different implementations of array filtering
const elements = [];
const element = {
a: 3,
b: true,
c: [1,2,3],
d: {},
e: null,
f: undefined,
xxx: "asdf"
};
@ximex
ximex / pokemongo_export.sql
Created July 25, 2016 22:37
Pokemon Go SQLite Export to CSV
-- pokemon.csv
/*
SELECT *, 'XX:' || SUBSTR(disappear_time, 15, 5) as time FROM pokemon ORDER BY disappear_time DESC;
*/
-- spawnpoint_count.csv
/*
SELECT * FROM (
SELECT spawnpoint_id, latitude, longitude, COUNT(*) as count FROM pokemon GROUP BY spawnpoint_id
) ORDER BY count DESC;
@ximex
ximex / number.js
Created September 10, 2014 08:20
Some helpfull methods for numbers
if (!Number.prototype.isBetween) {
Number.prototype.isBetween = function (low, high) {
if (isNaN(this)) {
throw new Error('Invalid Number: ' + this);
}
if (isNaN(low) || isNaN(high)) {
throw new Error('Invalid Parameter Types: ' + low + ', ' + high);
}
@ximex
ximex / array.js
Last active August 29, 2015 14:05
Some helpfull methods for arrays
// checks if an array contains a specific object
Array.prototype.contains = function(obj) {
var i = this.length;
while (i--) {
if (this[i] === obj) {
return true;
}
}
return false;
};
@ximex
ximex / gist:79a9ac90b7fda6187fee
Created August 20, 2014 14:15
Extract hashtags from messages
var text = 'Some bla bla with #hashtags inside. ## and #this# works too but # and this# not.';
var regex = new RegExp('\\B#([^\\s]+)', 'gm');
var hashtags = text.match(regex);