Skip to content

Instantly share code, notes, and snippets.

View MiniCodeMonkey's full-sized avatar

Mathias Hansen MiniCodeMonkey

View GitHub Profile
/*
This query returns the id's of stores which are open right now.
The date field for an opening hour can be either an explicit date or a weekday, an explicit date has higher priority than a weekday, and thus overrides a weekday.
A store is considered closed the whole day if there is an explicit date set (not a weekday) and closed=1 - or - no opening_hour is registered for the store on the day
Example data:
store_id date open_time close_time closed dayandnight closes_after_midnight
---------- -------- ---------- ---------- ------- ------------ ----------------------
@MiniCodeMonkey
MiniCodeMonkey / Find yourself in a project
Created June 16, 2012 19:13
Basecamp - Find yourself in a project
/*
* Instructions:
* Paste one of the following snippets in your browsers Javascript console
*/
// Remove all others than yourself
var n = "Mathias Hansen"; $("li .todo").each(function () { if ($.trim($(this).find("span .pill").find("span").html()) != n) { $(this).remove(); } });
// Mark your name with a color
var n = "Mathias Hansen"; $("li .todo").each(function () { var o = $(this).find("span .pill").find("span"); if ($.trim(o.html()) == n) { o.css('color', '#000'); o.parent().css('background-color', 'yellow'); } });
@MiniCodeMonkey
MiniCodeMonkey / gist:2942281
Last active October 6, 2015 05:17
Basecamp - Find yourself in a project
/*
* Instructions:
* Paste one of the following snippets in your browsers Javascript console
*/
// Remove all others than yourself
var n = "Mathias Hansen"; $("li.todo").each(function () { if ($.trim($(this).find("span .pill").find("span span").html()) != n) { $(this).remove(); } });
// Mark your name with a color
var n = "Mathias Hansen"; $("li.todo").each(function () { var o = $(this).find("span .pill").find("span span"); if ($.trim(o.html()) == n) { o.css('color', '#000'); o.parent().css('background-color', 'yellow'); } });
<?php
public function getOpenStoresCount()
{
$textualDateCondition = OpeningHour::getTextualDateQuery(); // Use the helper function from OpeningHour
$query = "SELECT
COUNT(*)
FROM `stores`
WHERE id IN (
SELECT store_id FROM opening_hours WHERE date = CURDATE()
AND
@MiniCodeMonkey
MiniCodeMonkey / gist:4497704
Created January 9, 2013 22:44
Bikeshare Rentals API Output
[
{
"start_station": "14th & Rhode Island Ave NW",
"start_date": "01-09-2013 8:28 am",
"end_station": "8th & Eye St SE / Barracks Row",
"end_date": "01-09-2013 8:54 am",
"duration_seconds": 1547,
"duration": "25 minutes, 47 seconds",
"cost": 0
},
var currentPage = 1;
function nextPage()
{
// Næste side
var nextPage = $("#page" + (currentPage + 1));
// Tjek om næste side eksisterer
if (nextPage.length != 0)
{
function goToPage(pageIndex)
{
// Ny side
var newPage = $("#page" + pageIndex);
// Tjek om ny side eksisterer
if (newPage.length != 0)
{
// Skjul nuværende side
$("#page" + currentPage).hide();
@MiniCodeMonkey
MiniCodeMonkey / fdsafds
Created January 23, 2013 14:46
fdsafdsaf
fdsa
@MiniCodeMonkey
MiniCodeMonkey / gist:5729249
Last active December 18, 2015 04:59
.io not responding with name servers
mini@codemonkey:~$ nslookup filepicker.io
Server: 8.8.4.4
Address: 8.8.4.4#53
** server can't find filepicker.io: NXDOMAIN
mini@codemonkey:~$ nslookup www.filepicker.io
Server: 8.8.4.4
Address: 8.8.4.4#53
<?php
$aws_key = '<key>';
$s3_secret = '<secret>';
$bucket_name = '<bucket>';
// Duration before request expires
$duration = (60 * 5); // 5 minutes
$objectName = $_GET['name'];