Skip to content

Instantly share code, notes, and snippets.

View name-k's full-sized avatar
💢

Mykhailo Pronin name-k

💢
  • Nuix
  • Homeless
View GitHub Profile
@name-k
name-k / ContentEditableLabel.js
Last active August 29, 2015 14:26 — forked from andrewgleave/ContentEditableLabel.js
An editable React.js label element based on the contenteditable attribute
/** @jsx React.DOM */
'use strict';
var React = require('react');
var ContentEditableLabel = React.createClass({
propTypes: {
tag: React.PropTypes.func,
@name-k
name-k / conemu.py
Last active August 29, 2015 14:17 — forked from batandwa/conemu.py
import sublime, sublime_plugin, os, subprocess
class ConemuCommand(sublime_plugin.TextCommand):
def run(self, edit):
if os.name == "nt":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(('c:/Program Files (x86)/ConEmu/ConEmu.exe', '/single', self.view.file_name()),
@name-k
name-k / php - Random file includ from path-to-folder
Created June 20, 2014 20:54
php - Random file includ from path-to-folder
<?php
$path = '/path/to/directory/'; // remeber trailing slash!
$handle = opendir ($path);
while (($filename = readdir ($handle)) !== false)
{
if ($filename != '.' && $filename != '..')
{
$file_array[] = $filename;
}
}
@name-k
name-k / .htaccess - Expires.htaccess
Created December 22, 2013 09:48
Expires Expires headers are an awesome way of setting long cache expirations on your files. Setting long expiration times on your static files (CSS, images, JavaScript, etc.) can be a massive performance boost! You may be asking yourself about updating your files and issues with new file versions not being update. Add a querystring to your file …
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
@name-k
name-k / .htaccess - Allow Cross-Domain Images with CORS.htaccess
Created December 22, 2013 09:47
Allow Cross-Domain Images with CORS Images are usually cool to serve from a different domain but if you want access to their data with canvas, you're in trouble. This snippet allows you to get raw image data via canvas:
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch "\.(cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
@name-k
name-k / .htaccess - Allow Cross-Domain Fonts with CORS.htaccess
Last active January 1, 2016 02:39
Allow Cross-Domain Fonts with CORS I had no idea how big of a response I'd have when I first posted about cross-domain fonts. They're a big, confusing problem for people but HTML5BP also has a solution:
<IfModule mod_headers.c>
<FilesMatch "\.(eot|otf|ttc|ttf|woff)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
@name-k
name-k / .htaccess - Compress Served Files by MIME Type.htaccess
Created December 22, 2013 09:46
Compress Served Files by MIME Type There are a number of file types we know we want compressed on the way out, and with mod_deflate, we can direct the server to do so:
<IfModule mod_deflate.c>
# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
@name-k
name-k / .htaccess - Block Access to Hidden Files and Directories.htaccess
Created December 22, 2013 09:46
Block Access to Hidden Files and Directories We try to push our code to productions servers without hidden files and directors, like our revision system directors, but that doesn't always happen. This snippet prevents those files from being accessible:
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
// from http://stackoverflow.com/a/11381730/989439
function mobilecheck() {
var check = false;
(function(a){if(/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|