Skip to content

Instantly share code, notes, and snippets.

View nahakiole's full-sized avatar

Robin Glauser nahakiole

View GitHub Profile
@nahakiole
nahakiole / gist:6094062a75210268137ae1dc6e29316e
Created December 4, 2023 16:33
Interrupt OpenAI ChatGPT
// function that presses aria-label="Stop generating" when pressing escape key
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
let stopGeneratingButton = document.querySelector('[aria-label="Stop generating"]');
if (stopGeneratingButton) {
// trigger click event
stopGeneratingButton.click();
}
}
});
@nahakiole
nahakiole / gist:a3e21290483a4faba26ff12309eb83c5
Created May 26, 2021 07:56
NanoHTTP Webserver that serves Websocket and HTTP.
import android.os.Build;
import android.util.Log;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import fi.iki.elonen.NanoHTTPD;
import fi.iki.elonen.NanoWSD;
@nahakiole
nahakiole / convertor.php
Created May 7, 2021 09:20
LIRC .conf file to Raw IR Code Convertor
<?php
$lines = file('./config.txt');
$config = array();
foreach ($lines as $l) {
$l = trim(preg_replace(["/\s+\#.*/", "/\s+/"], ["", " "], $l));
preg_match("/^(?P<key>\w+)(\s|\t)+(?P<value>.*)$/", $l, $matches);
if (isset($matches['key'])) {
$config[$matches['key']] = $matches['value'];
@nahakiole
nahakiole / flatastic.js
Created March 27, 2021 09:44
Simple Flatastic API Library for NodeJS
const request = require('request');
exports.Flatastic = function Flatastic(apikey) {
this.apikey = apikey;
Flatastic.prototype.request = function (url, option, cb){
const options = {
@nahakiole
nahakiole / fizzbuzz.c
Created June 9, 2015 13:02
Fizzbuzz in C
#include <stdio.h>
int main(){
for (int i = 0; i<100; i++){
if (i % 15 == 0){
printf("FizzBuzz\n");
}
else if (i % 5 == 0){
printf("Fizz\n");
}
@nahakiole
nahakiole / map.php
Last active August 29, 2015 14:18
Create map of http://lotrproject.com/map as a big picture.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST , false);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@nahakiole
nahakiole / color.js
Created April 3, 2015 05:50
A random color generator snippet
!function(window){
var subColour = function(){ return Math.floor(Math.random()*255).toString(16); };
window.Beautiful = function(){
return '#'+subColour()+subColour()+subColour();
}
}(window)
/*-----------------------------------------------------------------------------------*/
/* RETINA.JS
/*-----------------------------------------------------------------------------------*/
(function () {
var regex = /(media\/cache\/filter_[A-Z]+)/i //Added this
function t(e) {
this.path = e;
var t = this.path.split("."),
n = t.slice(0, t.length - 1).join("."),
@nahakiole
nahakiole / unzipper.desktop
Created October 12, 2014 16:02
A 1 click un-zipper for archives which uses file-roller.
[Desktop Entry]
Name=Unzipper
Type=Application
Exec=file-roller -h %U
Terminal=false
Icon=file-roller
MimeType=application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-ar;application/x-arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/x-deb;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lhz;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-rzip;applica
@nahakiole
nahakiole / maths.sh
Created October 2, 2014 15:55
Add all numbers from a file seperated by line break
cat file | grep -Eo "[0-9]+" | tr '\n' '+' | rev | cut -c 2- | rev | bc