Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / .htaccess
Last active December 14, 2015 22:39
CodeIgniter default
##### Recommended CodeIgniter Code #####
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
$(".social a",ifrm.contentWindow.document).social();
// social Buttons
// When a user clicks an item this function determines how to create a social button from it.
$.fn.social = function(){
//Add popup functionality for share buttons
return $(this).each(function(){
var service = this.className.match(/social_([a-z]+)/);
@slav123
slav123 / formatMoney.coffee
Created March 19, 2013 22:50
money format coffee script
Number::formatMoney = (decimalPlaces, decimalChar, thousandsChar) ->
n = this
c = decimalPlaces
d = decimalChar
t = thousandsChar
c = (if isNaN(c = Math.abs(c)) then 2 else c)
d = (if d is undefined then "." else d)
t = (if t is undefined then "," else t)
s = (if n < 0 then "-" else "")
i = parseInt(n = Math.abs(+n or 0).toFixed(c)) + ""
@slav123
slav123 / getHiddenDimensions.js
Created April 11, 2013 01:33
jquery extensions get's hidden layer height
//Optional parameter includeMargin is used when calculating outer dimensions
(function($) {
$.fn.getHiddenDimensions = function(includeMargin) {
var $item = this,
props = { position: 'absolute', visibility: 'hidden', display: 'block' },
dim = { width:0, height:0, innerWidth: 0, innerHeight: 0,outerWidth: 0,outerHeight: 0 },
$hiddenParents = $item.parents().andSelf().not(':visible'),
includeMargin = (includeMargin == null)? false : includeMargin;
var oldProps = [];
@slav123
slav123 / sublime2.json
Created April 19, 2013 23:48
sublime default bindings
[
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol", "extend": false} },
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend" : true} },
{ "keys": ["shift+left"], "command": "move_to", "args": {"to": "bol", "extend": true} },
{ "keys": ["shift+right"], "command": "move_to", "args": {"to": "eol", "extend": true} },
{ "keys": ["alt+left"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["alt+right"], "command": "move_to", "args": {"to": "eol", "extend": false} }
]
@slav123
slav123 / myretina.js
Created April 21, 2013 06:03
hi res image for images with class hires
$(function () {
if (window.devicePixelRatio == 2) {
var images = $("img.hires");
// loop through the images and make them hi-res
for(var i = 0; i < images.length; i++) {
// create new image name
@slav123
slav123 / destroy-modal.js
Created April 24, 2013 23:16
destroy twitter modal after hide - ajax
// destroy image modal
$('.modal').on('hidden', function () {
$(this).data('modal', null);
});
//latest bootstrap
$(document).ready(function() {
$('#myModal').on('hidden.bs.modal', function (e) {
$(this).removeData('bs.modal');
@slav123
slav123 / node.js install linux
Created May 5, 2013 08:34
install node.js on centos
The good news is that, we have nave, a Virtual Environments for Node, to help us.
https://github.com/isaacs/nave
Installing nodejs is dead easy now.
$ wget https://raw.github.com/isaacs/nave/master/nave.sh
$ chmod +x nave.sh
$ ./nave.sh install 0.8.8
$ ./nave.sh use 0.8.8
@slav123
slav123 / export.php
Created June 7, 2013 05:51
export file stream in PHP
<?php
$fileName = 'somefile.csv';
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename={$fileName}");
header("Expires: 0");
header("Pragma: public");
@slav123
slav123 / cors.js
Created June 8, 2013 12:30
node.js express - allow CORS
app.use(function(req, res, next) {
var oneof = false;
if(req.headers.origin) {
res.header('Access-Control-Allow-Origin', req.headers.origin);
oneof = true;
}
if(req.headers['access-control-request-method']) {
res.header('Access-Control-Allow-Methods', req.headers['access-control-request-method']);
oneof = true;
}