Skip to content

Instantly share code, notes, and snippets.

View honsa's full-sized avatar
💭
I am just a human

honsa.ch honsa

💭
I am just a human
View GitHub Profile
@honsa
honsa / index.html
Created July 4, 2018 12:31
Styled JavaScript Countdown Clock
<h1>Countdown Clock</h1>
<div id="clockdiv">
<div>
<span class="days"></span>
<div class="smalltext">Days</div>
</div>
<div>
<span class="hours"></span>
<div class="smalltext">Hours</div>
</div>
@honsa
honsa / weather.svg
Created July 3, 2018 14:09
Displaying an animated icon for the current weather at any given location.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@honsa
honsa / guetzli.py
Last active June 29, 2018 14:16
thumbor optimizer support for guetzli
#!/usr/bin/python
# -*- coding: utf-8 -*-
# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki
#guetzli compression for thumbor
#https://gist.github.com/honsa/bf972693bc1452d42acc1d87d0ce18e1
# Licensed under the MIT license:
@honsa
honsa / swipe-events.js
Created June 13, 2018 15:29
Detect swipe events vanilla javascript
function swipeEvents(){
// patch CustomEvent to allow constructor creation (IE/Chrome) - resolved once initCustomEvent no longer exists
if ('initCustomEvent' in document.createEvent('CustomEvent')) {
window.CustomEvent = function (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
let evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
@honsa
honsa / .htaccess
Last active May 31, 2018 16:47
gzip apache
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
@honsa
honsa / time2string.php
Last active May 31, 2018 17:01
relative time string from timestamp
function time2string($timestamp){
$now = new DateTime(date('Y-m-d H:i:m.s'));
$searched = new DateTime(date('Y-m-d H:i:m.s', $timestamp));
$diff = $searched->diff($now);
if($diff->y > 0){
if($diff->y === 1){
return 'vor einem Jahr';
} else {
return 'vor ' . $diff->y . ' Jahren';
@honsa
honsa / xhrInterception.js
Last active May 18, 2018 20:15
xhr interception
(function (open) {
XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
this.addEventListener("readystatechange", function () {
let state = this.readyState;
console.log(this);
if (this.readyState === 4) {
//here you go
}
}, false);
@honsa
honsa / oauth.php
Created May 3, 2018 19:36
oauth php
$client = new Google_Client();
$client->setAuthConfig('client_secret.json');
$client->setAccessType("offline"); // offline access
$client->setIncludeGrantedScopes(true); // incremental auth
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/oauth/index.php');
$auth_url = $client->createAuthUrl(); ?>
<button onclick="window.location.href = '<?= $auth_url ?>' ">login</button>
@honsa
honsa / custom.yml
Created March 23, 2018 13:55
SVGO custom config
plugins:
- cleanupIDs: true
- removeStyleElement: true
- removeUselessStrokeAndFill: true
- removeEmptyText: true
- removeEmptyContainers: true
- removeScriptElement: true
- removeUnusedNS: true
- removeEmptyAttrs: true
@honsa
honsa / font-big.scss
Last active March 9, 2018 19:24
dynamic font size with sass and media query
/*
https://gist.github.com/honsa/98c25b18b773e2944e32a2f3fdc9a9d7
*/
@mixin font-big($additionalValue: 0%, $op: '+') {
@if($op == '+'){
font-size: calc(60px + #{$additionalValue});
} @else {
font-size: calc(60px - #{$additionalValue});