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
lutsen / A Google Drive push notifications.md
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 notifications.md

Activate notifications for the file with ID [file-id] by posting some JSON to this URL: https://www.googleapis.com/drive/v3/files/[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
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.
$(this).addClass('active');
$('.collage').eq( $(this).index() ).addClass('active');
@lutsen
lutsen / removedirectory.php
Created Apr 19, 2015
Remove a directory and it's contents.
View removedirectory.php
<?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
lutsen / getpath.php
Created Apr 19, 2015
Get the absolute path of a file in PHP
View getpath.php
<?php echo dirname(__FILE__); ?>
@lutsen
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
// http://stackoverflow.com/questions/18313576/confirmation-dialog-on-ng-click-angularjs
// http://plnkr.co/edit/YWr6o2?p=preview
angular.module('yourApp')
.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
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
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: http://codepen.io/anon/pen/dPGggg
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) {
toggleMenu();
@lutsen
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 http://www.jongales.com/blog/2009/01/27/php-class-for-threaded-comments/
View Threaded.php
<?php
// From http://www.jongales.com/blog/2009/01/27/php-class-for-threaded-comments/
// This modified code now returns an array.
class Threaded {
public $parents = array();
public $children = array();
@lutsen
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() {
$('#mainimg').attr(
'src',
@lutsen
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">
<head>
<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="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
You can’t perform that action at this time.