Skip to content

Instantly share code, notes, and snippets.

View niorad's full-sized avatar
🏠
Working from home

Antonio Radovcic niorad

🏠
Working from home
View GitHub Profile
@niorad
niorad / drawSVGPaths.js
Created December 6, 2013 12:50
This script can be used to achieve a SVG-Animation-Effect similar to the one on http://www.polygon.com/a/ps4-review It takes all paths in an SVG-Element, hides them and draws them into the page. The method is explained in http://product.voxmedia.com/post/68085482982/polygon-feature-design-svg-animations-for-fun-and An example can be found at htt…
//inspired by http://product.voxmedia.com/post/68085482982/polygon-feature-design-svg-animations-for-fun-and
function drawSVGPaths() {
'use strict';
//grab all PATHs from an SVG-Element
var paths = $('.svganimate path');
//for each PATH..
@niorad
niorad / SpawnPrefab.cs
Last active August 29, 2015 14:16
Prefab Instantiation Script for Unity3D. Has rounds and pauses between rounds.
using UnityEngine;
using System.Collections;
public class SpawnPrefab : MonoBehaviour {
public Transform prefabSpawnee;
public float interval = 1;
public int instancesPerRound = 5;
public float pauseBetweenRounds = 3f;
@niorad
niorad / gulp-concat-server
Created July 1, 2015 15:07
Gulp–Recipe for watching and concatenating JS-Files plus server
var gulp = require('gulp');
var concat = require('gulp-concat');
var connect = require('gulp-connect');
gulp.task('js', function() {
gulp.src(['src/**/*.js'])
.pipe(concat('app.js'))
.pipe(gulp.dest('.'))
.pipe(connect.reload())
});
@niorad
niorad / vimshortcuts.md
Last active January 29, 2016 12:08
Some useful VIM-Shortcuts and Commands

In command mode

  • ddp Swap position of current line with next line (dd = Delete line, which also yanks it; p = Paste yanked line)
  • YP Duplicate current line (Y = Yank entire line; P = Paste line above active line (p for below))
  • dat Delete the current tag and its contents (d = Delete; a = Around; t = Tag)

In Visual Mode

  • :w filename.txt Saves the current selection as a new file filename.txt (w = Write)

In NERDTree

@niorad
niorad / gofunction.hs
Created January 23, 2016 18:59
Haskell Go-Function Example
divideBy x y = go x y 0
where go a b count
| a < b = (count, a)
| otherwise = go (a - b) b (count + 1)
@niorad
niorad / cesar.hs
Created January 29, 2016 08:33
Cesar-Cipher in Haskell
module CesarCipher where
import Data.Char
wrapMin = 97
wrapMax = 122
shifty x
| x > wrapMax = x - wrapMax + wrapMin
| otherwise = x
@niorad
niorad / diagonalline.scss
Created January 29, 2016 13:41
A diagonal line through a box
.container {
position: relative;
overflow: hidden;
&:after {
position: absolute;
content: ' ';
width: 100%;
@niorad
niorad / lazyload.html
Created January 30, 2016 17:16
Short Vanilla-JS Image LazyLoading
<img src="" data-src="myphoto.jpg" class="js-lazyload" alt="Photo">
<noscript>
<img src="myphoto.jpg" alt="Photo">
</noscript>
<script>
var images = document.getElementsByClassName("js-lazyload");
for(var i = 0; i < images.length; i++) {
images[i].attributes.src.value = images[i].attributes["data-src"].value;
@niorad
niorad / minimal_jquery_accordion.js
Created April 20, 2016 18:47
Minimal jQuery-Accordion
$('[data-accordion-toggler]').on("click", function () {
$(this).next().toggle();
$('[data-toggle-content]').not($(this).next()).hide();
});
@niorad
niorad / uiViewToPhotoLibrary.swift
Created April 22, 2016 06:34
Save UIView in User's Photo-Library
UIGraphicsBeginImageContextWithOptions(myView.bounds.size, true, 0)
myUiView.drawViewHierarchyInRect(myView.bounds, afterScreenUpdates: true)
let myImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil)