Skip to content

Instantly share code, notes, and snippets.

View robbestad's full-sized avatar
🎯
Focusing

Sven Anders Robbestad robbestad

🎯
Focusing
View GitHub Profile
@robbestad
robbestad / License.md
Created October 19, 2012 10:20
Protect against XSS injection from _GET and _POST

Copyright (c) 2012, Sven Anders Robbestad All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY

@robbestad
robbestad / IsPrime.php
Created November 8, 2012 21:15
Check the prime number of any number
<?php
/*
* IsPrime.php
* Check the prime number of any number
* Tests included
* Will efficiently calculate and populate an array of prime numbers
*
* A prime number is a number that is not divisible evenly by any other
* numbers other than by one and itself.
*
@robbestad
robbestad / utfordring3.php
Last active December 19, 2015 01:38
Kode som dekrypterer utfordring 3 fra Sikkerhetsbloggens konkurranse på http://blogg.nsm.stat.no/archives/3775
<?php
# Utf 3 - Sikkerhetsbloggen
# Sven A Robbestad 24 jun 2013
# http://blogg.nsm.stat.no/archives/3775
# Dekrypter følgende:
# 32 19 1C 12 1B 57 2F 38 25 57 04 18 1A 57 13 12
# 03 03 12 57 12 05 57 18 11 03 12 57 15 05 02 1C
# 03 57 16 01 57 1A 16 1B 00 16 05 12 59 57 3C 16
# 19 04 1C 1D 12 57 13 02 57 12 05 57 1E 19 03 12
# 05 12 04 04 12 05 03 57 1E 57 16 19 16 1B 0E 04
@robbestad
robbestad / .htaccess
Last active December 19, 2015 04:19
.htaccess stuff
# Apache 1.3>
# Force download certain file types.
# REPLACES
# AddType application/octet-stream .doc .mov .avi .pdf .xls .mp4
<FilesMatch "\.(docx?|txt|rtf|avi|mov|mp[34]|pdf|xls|jpe?g|tiff?)$">
Header add Content-Disposition "attachment"
</FilesMatch>
# Speed things up
@robbestad
robbestad / jquery.js
Last active December 19, 2015 04:19
jQuery tricks
//jquery if exists DOM element
if ( $('#myDiv').length ) {
//exists
}
@robbestad
robbestad / borders.css
Created June 30, 2013 20:13
CSS - border without markup
/*------------------------------------*\
BORDERS
\*------------------------------------*/
/* Create a series of empty pseudo-elements... */
html:before,html:after,body:before,body:after{
content:"";
background:#dad8bb;
position:fixed;
display:block;
@robbestad
robbestad / Orientation.js
Created June 30, 2013 20:14
Javascript action on orientation change
window.onorientationchange = function(){
var orientation = window.orientation;
// Look at the value of window.orientation:
if (orientation === 0){
// iPad is in Portrait mode.
@robbestad
robbestad / files.php
Created June 30, 2013 20:17
Linked list of files with PHP
<ol>
<?php
$dir = "*";
foreach(glob($dir) as $file)
{
?>
<li><p><a href='<?=$file?>'><?=basename($file)?></a></p></li>
<?php
}
?>
@robbestad
robbestad / kerning.css
Created June 30, 2013 20:20
Kerning and font legibility css
/* kerning and readability improvement in Safari and Chrome */
html { text-rendering: optimizeLegibility; }
/* Make fonts appear smoother in Safari & Chrome */
html { -webkit-font-smoothing: antialiased; }
@robbestad
robbestad / opacity.css
Created June 30, 2013 20:20
CSS - opacity for ie6-7 & 8
//for ie6-7
.see-through {
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
}
// or
.see-through {
filter: alpha(opacity=80);