Skip to content

Instantly share code, notes, and snippets.

View luhof's full-sized avatar
🍕
www.lucas.cool

Lucas Hörand luhof

🍕
www.lucas.cool
View GitHub Profile
@luhof
luhof / aura-webview-sample.html
Created January 4, 2021 13:53
Aura Webview Sample
<html>
<head>
<style>
/* CSS RESET to reduce browser disparities */
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}
</style>
<style>
/* AUR
@luhof
luhof / parse-url-params.js
Created January 4, 2018 14:03
puts GET parameters from an url into an object
// from random SO answer
var params = {};
var url = location.search;
var parts = url.substring(1).split('&');
for (var i = 0; i < parts.length; i++)
{
var nv = parts[i].split('=');
if (!nv[0]) continue;
params[nv[0]] = nv[1] || true;
@luhof
luhof / ng-thumb.js
Created November 2, 2017 10:14
ng-thumb quick'n'dirty responsive fork
'use strict';
/**
* The ng-thumb directive
* @author: nerv
* @version: 0.1.2, 2014-01-09
*/
/*
made responsive by Lucas - 2017
*/
@luhof
luhof / angular-chain-promises.js
Created September 25, 2017 09:35
angular chain promises in order
/**
@name processArray
@description chain promises IN ORDER.
@public
*/
function processArray(array, fn) {
var index = 0;
return new Promise(function(resolve, reject) {
function next() {
@luhof
luhof / ajax-no-jquery.js
Created August 10, 2017 13:05
ajax function with no jquery
// Ajax function with no jQuery - directly ripped from jQuery, but without the jQuery.
// this function is always handy and boring to rewrite everytime needed
// from StackOF user Hors Sujet
function ajax(option) { // $.ajax(...) without jquery.
if (typeof(option.url) == "undefined") {
try {
option.url = location.href;
} catch(e) {
var ajaxLocation;
ajaxLocation = document.createElement("a");
@luhof
luhof / .htaccess
Created June 9, 2017 13:14
force cache clean by adding a timestamp to minified files
Options +Indexes
Options +FollowSymLinks
RewriteEngine on
#smth like this
#RewriteRule ^(.*/.+\.)[0-9]{12}\.(js|css)$ $1$2 [L]
@luhof
luhof / ng-static-include.js
Created May 18, 2017 13:49
ng static include
/* Static Include
* same as ng-include w/o creating a child scope.
* usage : <div static-include="mypath.html"/>
*/
app.directive('staticInclude', fnStaticIncludeDirective);
function fnStaticIncludeDirective($http, $templateCache, $compile)
{
return function(scope, element, attrs)
@luhof
luhof / angular-router-console-traces.js
Created May 3, 2017 15:39
Angular router console debug
// Credits: Adam's answer in http://stackoverflow.com/a/20786262/69362
// Paste this in browser's console
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart to '+toState.to+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
});
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeError - fired when an error occurs during transition.');
@luhof
luhof / physics_link_parameters.java
Created March 13, 2017 10:58
Physics link parameters
@luhof
luhof / sticky-menu.js
Last active August 18, 2016 13:34
Sticky menu when scrolled past it
$(document).ready(function() {
var menu = $('#navbar-container');
var origOffsetY = menu.offset().top;
function scroll() {
if ($(window).scrollTop() >= origOffsetY) {
$('#navbar-container').addClass('sticky');
$('#wrapper').addClass('menu-padding');
} else {
$('#navbar-container').removeClass('sticky');
$('#wrapper').removeClass('menu-padding');