Skip to content

Instantly share code, notes, and snippets.

View lutsen's full-sized avatar

Lútsen Stellingwerff lutsen

View GitHub Profile
@lutsen
lutsen / A Google Drive push notifications.md
Last active May 13, 2022 20:22 — 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.

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",
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
# Force www
# - Exclude urls starting with loaclhost
@lutsen
lutsen / select_element_at_same_position.js
Created March 23, 2017 15:18
Select elements at the same position in a different node with jQuery.
// 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');
// Image popover
// http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/super-simple-lightbox-with-css-and-jquery/
jQuery(document).ready(function($) {
$('.lightbox_trigger').click(function(e) {
//prevent default action (hyperlink)
e.preventDefault();
//Get clicked link href
var image_href = $(this).attr("href");
var flickr_link = $(this).data("flickr");
/*
@lutsen
lutsen / setup_carousel.js
Created November 13, 2013 21:40
A function to initiate a dynamically generated Bootstrap 3.0.2 carousel. The function adds an .active class to the first item, and adds carousel-indicators li elements for all carousel items. Handy if all carousel item code needs to be the same, or you don't know how many items your carousel will have.
@lutsen
lutsen / same_height.js
Last active December 28, 2015 02:39
Get highest element of a class of each containing parent element, and give all elements in this parent element this height. Uses jQuery.
function sameHeight(target) {
// Reset
$(target).each(function() {
$(this).parent().data('height', 0);
});
// Get highest element of each containing parent element
$(target).each(function() {
if ($(this).parent().data('height') < $(this).height()) {
$(this).parent().data('height', $(this).height());
}
@lutsen
lutsen / hilight_menuitem.js
Last active December 27, 2015 17:19
Hilight a menu item when scrolling past the #id anchor using jQuery. A.k.a. ScrollSpy.
// The menu should have the id #menu
// ID's that have to work with this should have the class .scroll-anchor
function highlightMenuItem(anchor) {
var menu_item = $('#menu a[href="#/'+anchor+'"]');
if (menu_item && !menu_item.hasClass('active')) {
$('#menu .active').removeClass('active');
menu_item.addClass('active');
}
}
@lutsen
lutsen / .htaccess
Created November 5, 2013 08:40
Clean URL's: Use .htaccess URL rewrite and PHP to get clean URL's.
#php_flag display_startup_errors on
#php_flag display_errors on
#php_flag html_errors on
# Just in case...
Options +FollowSymlinks
RewriteEngine on
@lutsen
lutsen / stick_to_top.js
Last active December 27, 2015 09:09
Stick a menu (or other element) to the top of the page when scrolling past it, using jQuery.
var element_start_offset = 0;
var element_sticks = false;
function stickToTop(element) {
// You may need to insert a placeholder to prevent other content from "jumping"
// Make sure it has the same height as "element"
placeholder = element.substr(1)+'_placeholder';
if ($(document).scrollTop() >= element_start_offset.top && !element_sticks) {
$('<div id="'+placeholder+'">&nbsp</div>').insertAfter(element); // Insert placeholder
@lutsen
lutsen / scaffolding.less
Last active December 27, 2015 06:49
My take on a 12 colum grid in css. The columns in this grid have a percentual width, but the gutter has a pixel width. This way the grid should work in a container of any width. It uses CSS calc().
// SCAFFOLDING
// Define gutter width
@gutter: 20px;
// Some mixins
// For clearing floats like a boss h5bp.com/q
.clearfix {
*zoom: 1;