Skip to content

Instantly share code, notes, and snippets.

View jan53n's full-sized avatar
:octocat:
Focusing

Jansen jan53n

:octocat:
Focusing
View GitHub Profile
@jan53n
jan53n / translate.php
Last active June 13, 2020 07:03
Text Translation with custom key format
function trans($text, $data, $data_format = "[%s]")
{
$dataWithFormattedKeys = [];
array_map(function($key, $value) use ($data_format, &$dataWithFormattedKeys) {
$formattedKey = sprintf($data_format, $key);
$dataWithFormattedKeys[$formattedKey] = $value;
}, array_keys($data), $data);
return strtr($text, $dataWithFormattedKeys);
@jan53n
jan53n / toggle_gnome_night_light.sh
Created November 19, 2018 02:38
Toggle Gnome Night Light
# toggle gnome night light
if [ $(dconf read /org/gnome/settings-daemon/plugins/color/night-light-enabled) = true ]
then
dconf write /org/gnome/settings-daemon/plugins/color/night-light-enabled false
else
dconf write /org/gnome/settings-daemon/plugins/color/night-light-enabled true
fi
@jan53n
jan53n / unique.php
Last active September 21, 2018 16:17
A Unique Alphanumeric String with for an identification value.
// https://codebriefly.com/unique-alphanumeric-string-php/
function unique_code($id, $limit)
{
$randomId = $id . mt_rand();
return substr(base_convert(sha1(uniqid($randomId)), 16, 36), 0, $limit);
}
@jan53n
jan53n / index.js
Created June 24, 2018 04:36
running dialogflow-fulfillment on private server (without using firebase-functions)
const express = require('express');
const app = express();
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug';
var processWebhook = function(request, response) {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
@jan53n
jan53n / conky
Last active November 11, 2017 23:02
moved to yahoo weather api, made weather status case Insensitive on sed matching.
######################
# - Conky settings - #
######################
update_interval 1
total_run_times 0
net_avg_samples 1
cpu_avg_samples 1
if_up_strictness link
@jan53n
jan53n / latestAtomDeb.py
Created December 9, 2016 15:01
Latest atom stable build deb url
from urllib2 import urlopen
import json
release_response = urlopen("https://api.github.com/repos/atom/atom/releases")
release_data = json.load(release_response)
def deburl(assets):
for asset in assets:
if asset["content_type"] == "application/x-debian-package":
@jan53n
jan53n / pomodoro.py
Last active November 21, 2016 12:48
the usual pomodoro script (python, libnotify)
#! /usr/bin/env python3
# notify works on ubuntu (libnotify library)
from sys import argv
import time
import subprocess
import threading