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 / 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 / media_query.css
Created December 26, 2015 10:44
css media query boilerplate
/* Mobile first */
/* --- >= smartphones landscape --- */
@media screen and (min-width: 480px) {
}
/* --- >= tablets portrait --- */
@media screen and (min-width: 768px) {
@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" */
@sinky
sinky / for_each_file.sh
Created August 10, 2016 08:09
Do something for each file in a directory with bash (every time i don't remember)
for a in $(ls -1 *.txt); do echo $a; done