Skip to content

Instantly share code, notes, and snippets.

View nasal's full-sized avatar

Rudi Kovač nasal

View GitHub Profile
@nasal
nasal / touch.js
Created February 13, 2014 00:12 — forked from rogeruiz/touch.js
JS: handle touch events on multiple devices
function handleTouch (evt) {
var touchX, touchY, xOffset, yOffset;
if (window.navigator.msPointerEnabled) {
var bodyEl = document.getElementByTagName('body')[0];
bodyEl.style.msTouchAction = 'none';
bodyEl.style.touchAction = 'none';
}
// Normalize your touch events
touchX = evt.originalEvent.pageX || evt.originalEvent.changedTouches[0].screenX;
touchY = evt.originalEvent.pageY || evt.originalEvent.changedTouches[0].screenY;
@nasal
nasal / newfile.tex
Last active August 29, 2015 13:57
LaTeX: starter document
% -*- coding: utf-8 -*-
\documentclass[a4paper]{article}
\usepackage[slovene]{babel} % šumniki s \v{c}
\usepackage[utf8]{inputenc} % šumniki s č
\usepackage{mathtools} % za matematiko
\usepackage{amssymb} % za dodatne simbole, \mathbb{F, R, N..}
\title{My Title}
\author{My Name}
@nasal
nasal / slovenskeobcije.html
Last active August 29, 2015 14:02
HTML: Slovenske občine
<select name="obcina">
<option>
Izberi
</option>
<option value="192">
Ajdovščina
</option>
<option value="205">
Ankaran
</option>
@nasal
nasal / slevenskeregije.html
Last active August 29, 2015 14:02
HTML: Slovenske regije
<select name="regija">
<option>
Izberi
</option>
<option value="gorenjska">
Gorenjska regija
</option>
<option value="goriska">
Goriška regija
</option>
@nasal
nasal / slovenskamesta.html
Last active August 29, 2015 14:02
HTML: Slovenska mesta
<select name="mesto">
<option>
Izberi
</option>
<option value="Adlešiči">
Adlešiči
</option>
<option value="Ajdovščina">
@nasal
nasal / ssl.php
Created October 6, 2014 10:08
PHP: Force SSL
<?php
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
if(!headers_sent()) {
header("Status: 301 Moved Permanently");
header(sprintf(
'Location: https://%s%s',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
));
exit();
@nasal
nasal / fadeout.cs
Created January 6, 2015 11:48
C#: Fade out animation
var myControl = ControlName;
var a = new DoubleAnimation
{
From = 1.0,
To = 0.0,
FillBehavior = FillBehavior.Stop,
BeginTime = TimeSpan.FromSeconds(2),
Duration = new Duration(TimeSpan.FromSeconds(0.5))
};
var storyboard = new Storyboard();
@nasal
nasal / thread.cs
Created January 6, 2015 15:44
C#: Simple thread
new Thread(delegate()
{
Dispatcher.BeginInvoke(new Action(delegate()
{
// Do something in the "main" thread (the thread calling the new thread).
}));
// Do whatever you want.
Thread.Sleep(3000);
@nasal
nasal / current-method.cs
Created January 6, 2015 15:49
C#: Get current method name
System.Reflection.MethodBase.GetCurrentMethod().Name
@nasal
nasal / logout.php
Last active December 27, 2015 09:59
PHP: logout
<?php
if (isset($_GET['logout'])) {
session_start();
session_unset();
session_destroy();
session_write_close();
setcookie(session_name(),'',0,'/');
session_regenerate_id(true);
header('location: ./');
}