Skip to content

Instantly share code, notes, and snippets.

View shinmai's full-sized avatar
😫
coping admirably

Shi Saaristo shinmai

😫
coping admirably
View GitHub Profile
// ==UserScript==
// @name NAReadability
// @namespace http://script.nar
// @description Make NaR.com a bit more readable
// @include http://notalwaysright.com/*
// ==/UserScript==
var cont = document.getElementById('left');
var body = document.getElementsByTagName('body')[0];
var navi = document.getElementsByClassName('wp-pagenavi')[0];
@shinmai
shinmai / warwick.php
Last active December 5, 2017 00:41
Wordpress HTML-minifying
/**
* Warwick
* Very small HTML from WordPress. Place at the end of your theme's functions.php
* @version 0.8.0
* @link https://gist.github.com/shinmai/add32c1c61750fb6dd58cbf0525b4a9a
* @license http://www.wtfpl.net/txt/copying/ WTFPL
* @author Aapo Saaristo <aapo.saaristo@gmail.com>
*/
class Warwick{protected $html;public function __construct($h){$this->go($h);}public function __toString(){return $this->html;}protected function filter($h){preg_match_all('/<(?<script>script).*?<\/script\s*>|<(?<style>style).*?<\/style\s*>|<!(?<comment>--).*?-->|<(?<tag>[\/\w.:-]*)(?:".*?"|\'.*?\'|[^\'">]+)*>|(?<text>((<[^!\/\w.:-])?[^<]*)+)|/si',$h,$m,PREG_SET_ORDER);$o=false;$r=false;$h='';foreach($m as $t){$ta=(isset($t['tag']))?strtolower($t['tag']):null;$c=$t[0];if(is_null($ta)){$s=!empty($t['script'])||!empty($t['style']);if($c=='<!-- no-minify -->'){$o=!$o;continue;}else if(!$o&&$r!='textarea')$c=preg_replace('/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->/s','',$c);}else if($ta=='pre'||$ta=='textarea')$r=$ta
@shinmai
shinmai / expat.php
Created October 10, 2016 13:21
Don't include migrate.js in production, if you know you won't need it.
/**
* Expat
* Don't include migrate.js in production, if you know you won't need it.
* @param string &$scripts enqueued scripts
* @version 0.1.0
* @link https://gist.github.com/shinmai/7d5fdbb855850c526af5ae2b36613492
* @license http://www.wtfpl.net/txt/copying/ WTFPL
* @author Aapo Saaristo <aapo.saaristo@gmail.com>
*/
function expat( &$scripts){
/**
* NoDrama
* Excorsise everything blogging-related from Wordpress
* @version 0.1.0
* @link https://gist.github.com/shinmai/8448eaa9567fdc11383e42d00d3da8ba
* @license http://www.wtfpl.net/txt/copying/ WTFPL
* @author Aapo Saaristo <aapo.saaristo@gmail.com>
*/
function nbmb(){remove_action('welcome_panel','wp_welcome_panel');$metabox=array('dashboard_incoming_links'=>'normal','dashboard_activity'=>'normal','dashboard_primary'=>'side','dashboard_quick_press'=>'side','dashboard_recent_drafts'=>'side','dashboard_right_now'=>'normal','dashboard_recent_comments'=>'normal','dashboard_secondary'=>'side','wpe_dify_news_feed'=>'normal');foreach($metabox as $id=>$context)remove_meta_box($id,'dashboard',$context);}function nbsm(){$menu=array('edit.php','edit-comments.php','separator1','separator2','separator3');foreach($menu as $main)remove_menu_page($main);remove_submenu_page('tools.php','tools.php');remove_submenu_page('options-general.php','options-writing.php');remove_submenu_page('options-general.php','opt
/**
* WeePeeLeeks
* All pages are published
* @version 1.0.0
* @link https://gist.github.com/shinmai/de0fa9ac20cf4ea6ba8b7ce7cf5c2cf5
* @license http://www.wtfpl.net/txt/copying/ WTFPL
* @author Aapo Saaristo <aapo.saaristo@gmail.com>
*/
function weepeeleeks( $post ) {
if($post['post_type']==='page')
@shinmai
shinmai / looseChance.js
Created October 21, 2016 11:13
jquery-style queryselector shortcut at $ and a most barebones script loader
if(!$)var $=a=>{let r=document.querySelectorAll(a);return r.length>1?r:r[0]} // $('.class > div#heading') etc. returns an array if more than one match is found
((l,Z)=>{var d=(a)=>{return new Promise((c,d)=>{var b=document.createElement("script");b.onload=c,b.onerror=d,b.async=1,b.src=a,document.head.appendChild(b)})};Promise.all(l.split(",").map(a=>{return d('lib/'+a+'.js')})).then(Z)})(
'api,auth,../main', // loads lib/api.js, lib/auth.js & main.js. if your file layout is differnet, edit the call to d() at 2:201
X=>{console.log('scripts loaded')} // callback function to run when scripts have loaded
)
cmake_minimum_required(VERSION 3.6)
project(vko1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
add_executable("tehtava1-3" "tehtava1-3.cpp")
add_executable("tehtava4-6" "tehtava4-6.cpp")
add_executable("tehtava7-8" "tehtava7-8.cpp")
@shinmai
shinmai / Curved.shader
Created October 17, 2017 12:58 — forked from grimmdev/Curved.shader
Subway Surfer like Curved World Shader for Unity
Shader "Custom/Curved" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_QOffset ("Offset", Vector) = (0,0,0,0)
_Dist ("Distance", Float) = 100.0
}
SubShader {
Tags { "RenderType"="Opaque" }
Pass
{
//http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
// -- Distant functions
float sdPlane( vec3 p ) {return p.y+0.2;}
float sdSphere( vec3 p, float s ) {return length(p)-s;}
float sdCylinder( vec3 p, vec3 c ){ return length(p.xz-c.xy)-c.z; }
float udRoundBox( vec3 p, vec3 b, float r ){return length(max(abs(p)-b,0.0))-r;}
float udRoundBoxInf( vec3 p, vec2 b, float r ){return length(max(vec3(abs(p.xz)-b,0.0),0.0))-r;}
float maxcomp( vec3 p ) {return max(p.x,max(p.y,p.z));}
@shinmai
shinmai / sdfexample.glsl
Created November 13, 2017 21:37 — forked from kchapelier/sdfexample.glsl
hg_sdf + antialiase raymarch by iq + ashima noise
////////////////////////////////////////////////////////////////
//
// HG_SDF
//
// GLSL LIBRARY FOR BUILDING SIGNED DISTANCE BOUNDS
//
// version 2015-12-15 (initial release)
//
// Check http://mercury.sexy/hg_sdf for updates
// and usage examples. Send feedback to spheretracing@mercury.sexy.