Skip to content

Instantly share code, notes, and snippets.

View nahakiole's full-sized avatar

Robin Glauser nahakiole

View GitHub Profile
/*-----------------------------------------------------------------------------------*/
/* 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 / 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)
@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 / 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 / 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 / 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 / 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 / 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();
}
}
});