Skip to content

Instantly share code, notes, and snippets.

Lútsen Stellingwerff lutsen

Block or report user

Report or block lutsen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lutsen / A Google Drive push
Last active May 21, 2018 — forked from magnetikonline/dumprequest.php
How to set up Google Drive push notifications for a file, and test if they work by catching them and writing them in a file with a PHP script.
View A Google Drive push

Activate notifications for the file with ID [file-id] by posting some JSON to this URL:[file-id]/watch Authorization: Bearer auth_token_for_current_user Content-Type: application/json

Minimal JSON you need to POST:

  "id": "[some unique ID for your push, you can define it yourself but it mus be unique]",
  "type": "web_hook",
lutsen / select_element_at_same_position.js
Created Mar 23, 2017
Select elements at the same position in a different node with jQuery.
View select_element_at_same_position.js
// Use index() to find the position and eq()to select a different element on the same position.
$('.collage').eq( $(this).index() ).addClass('active');
lutsen / removedirectory.php
Created Apr 19, 2015
Remove a directory and it's contents.
View removedirectory.php
function removeDir($path) {
// Add trailing slash to $path if one is not there
if (substr($path, -1, 1) != "/") {
$path .= "/";
$normal_files = glob($path . "*");
$hidden_files = glob($path . "\.?*");
lutsen / getpath.php
Created Apr 19, 2015
Get the absolute path of a file in PHP
View getpath.php
<?php echo dirname(__FILE__); ?>
lutsen / ngconfirmclick.js
Last active Aug 29, 2015
An Angular directive to show a javascipt confirmation message when the user clicks a page element. The ng-confirm-click attribute contains the text in the confirmation window. The confirmed-click attribute contains the actual ation that is executed if the user confirms.
View ngconfirmclick.js
.directive('ngConfirmClick', function () {
return {
link: function (scope, element, attr) {
var msg = attr.ngConfirmClick || "Are you sure?";
var clickAction = attr.confirmedClick;
element.bind('click',function (event) {
lutsen / ImageController.js
Created Jan 20, 2015
Serving files from Modulus Cloud Storage with Sails
View ImageController.js
module.exports = {
get: function (req, res) {
res.sendfile( sails.config.uploaddir + req.param('dir') + '/' + req.param('file') );
// List the app-storage directory
listdir: function (req, res) {
var fs = require('fs');
return res.json( fs.readdirSync(sails.config.uploaddir) );
lutsen / togglemenu.js
Last active Aug 29, 2015
Hide a menu on the top of the page when scrolling down, and show it when scrolling up. Check out the example here:
View togglemenu.js
var menu_height = 80;
var menu_visible = true;
var old_scroll = $(window).scrollTop();
function checkMenu() {
new_scroll = $(window).scrollTop();
if (old_scroll < new_scroll && new_scroll > 0) {
// Scroll down
if (menu_visible == true) {
lutsen / Threaded.php
Last active Aug 29, 2015
Make a Threaded multi level array from a two level array with parent id's. For example comments or a page tree. The class returns an array. Original code from
View Threaded.php
// From
// This modified code now returns an array.
class Threaded {
public $parents = array();
public $children = array();
lutsen / swapmainimg.js
Created Apr 13, 2014
Swap a "main" image by hovering over a thumb image.
View swapmainimg.js
// Swap a "main" image by hovering over a thumb image.
// They both need to have the same scr, except for the "template" part.
$(function () {
$( '.thumbimg' ).each( function (i) {
$( this ).on({
mouseenter: function() {
lutsen / index.html
Created Mar 11, 2014
Make X-editable work with List.js in a Booststrap 3 styled table. The problem: X-editable will mess up the table layout when used on a <td> element. But List.js won't work if the table data is in another element inside the <td> element. The solution: create a <span> element every time the editable <td> is clicked, and remove it every time the X-…
View index.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>X-editable and List.js Datagrid</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="//">
You can’t perform that action at this time.