Skip to content

Instantly share code, notes, and snippets.

View sinky's full-sized avatar

Marco Krage sinky

View GitHub Profile
@sinky
sinky / index.html
Last active October 10, 2015 19:58
load gihub repos starred by user
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
@sinky
sinky / hide_table_rows.js
Created November 6, 2012 16:55
Initially show only X table rows
var numShown = 15; // Initial rows shown & index
// Hide rows and add clickable div
$('.cinematiclist').find('tr:gt(' + (numShown - 1) + ')').hide().end().append('<tr id="cinematicmore"><td colspan="4" style="cursor:pointer; text-align:center;">Zeige alle</td></tr>');
// onclick remove trigger an show full table
$('#cinematicmore').click(function(){
$('#cinematicmore').remove();
// Show all
@sinky
sinky / jquery.selecttext.js
Created December 3, 2012 10:19
jQuery Select Text
// Source: http://stackoverflow.com/a/987376/1461859 (http://jsfiddle.net/edelman/KcX6A/1506/)
jQuery.fn.selectText = function(){
var doc = document
, element = this[0]
, range, selection
;
if (doc.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(element);
@sinky
sinky / functions.php
Last active December 10, 2015 01:28
Hide Wordpress Category from Public using functions.php by manipulating SQL Query
// -------------------
// Hide Category from Public
// -------------------
add_filter('posts_where', 'private_category');
function private_category($where) {
$cat_id = "12" // Change Category ID
if( is_admin() OR is_user_logged_in() ) {
return $where; // show Posts
}else{
@sinky
sinky / example-script.js
Last active December 10, 2015 15:08
Add JS Files inline when then needed, but execute later/in footer.
;(function(){
var azurScript = {},
scriptDatastore = [];
azurScript.add = function(path, callback) {
scriptDatastore.push({path: path, callback: callback});
};
azurScript.exec = function() {
@sinky
sinky / fun_squid.php
Last active December 19, 2015 11:19
Make fun with Squid. Flip and replace images randomly
#!/usr/bin/php
<?php
$temp = array();
$folder = "squid/"; // http://proxyserver.de/$folder/
$wwwpath = "/var/www/"; // eg. /var/www/
stream_set_timeout(STDIN, 86400); // Extend stream timeout to 24 hours
if(!file_exists($wwwpath.$folder)) {
mkdir ($wwwpath.$folder);
test
@sinky
sinky / app.js
Last active January 2, 2016 02:18
QR Code Generator; Demo: http://bl.ocks.org/sinky/8235773
$(function() {
var data = location.hash.substring(1);
data = Base64.decode(data);
genQR(data);
$('#in').val(data);
$('#in').bind('keyup', function() {
var data = $(this).val();
genQR(data);
/* GCD */
function gcd (a, b) { return (b == 0) ? a : gcd (b, a%b); } // Source: http://stackoverflow.com/a/1186465
/* ratio is to get the gcd and divide each component by the gcd, then return a string with the typical colon-separated value */
function ratio(x,y) {c=gcd(x,y); return ""+(x/c)+":"+(y/c)}
ratio(1920,1080)
/* "16:9" */
ratio(320,240)
/* "4:3" */
/**
*
* Here's a thing that will look through all the text nodes of a document, and
* upon encountering an emoji codepoint, will replace it with an image.
* For now, those images are pulled from GitHub, which isn't very nice, so I
* need to find a more suitable host.
*
* Much of this code was gleaned from staring at the minified GitHub JS.
*
* Copyright (c) 2013 Mark Wunsch. Licensed under the MIT License.