Skip to content

Instantly share code, notes, and snippets.

View joonassandell's full-sized avatar

Joonas Sandell joonassandell

View GitHub Profile
@joonassandell
joonassandell / Regex: Remove comments
Last active August 29, 2015 14:14
Remove single and multiline comments
(^\/\/.*)|(\s+\/\/.*)|((\/\*)(.|\n)+?(\*\/))
(?:https?:\/\/)?(?:www\.)?youtu(?:.be\/|be\.com\/watch\?v=|be\.com\/v\/)(.{8,})
@joonassandell
joonassandell / SassMeister-input.scss
Last active September 14, 2015 12:50 — forked from pascalduez/SassMeister-input.scss
Some Sass string functions: capitalize, ucwords, camelize, ...
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// Capitalize string
// --------------------------------------------------------------------------------
// @param [string] $string
// --------------------------------------------------------------------------------
// @return [string]
@joonassandell
joonassandell / JS: Closest number
Last active September 13, 2016 14:38 — forked from vipickering/closestNumberArray.js
Find closest number in ES6
const closestNumber = (array, num) => {
const i = 0;
let minDiff = 1000;
let ans;
for (i in array){
const m = Math.abs(num - array[i]);
if (m < minDiff) {
minDiff = m;
@joonassandell
joonassandell / JS: detect font-face support
Last active September 13, 2016 14:38
Detecting font-face support
var ua = navigator.userAgent,
doc = document,
docEl = doc.documentElement;
/**
* Detect mobile "font-face" support
*
* Doesn't check support on desktop browsers
* so you should use Modernizr in combination with this
* UA detection to get the most out of it.
@joonassandell
joonassandell / JS: Detect touch
Last active September 13, 2016 14:46
Detect touch support
/**
* Detect "touch" support and act accordingly.
* Adds `touch` class and assumes there is `no-touch` class added in <html> element.
*/
let hasTouch = false;
const docEl = document.documentElement;
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch || navigator.msMaxTouchPoints) {
docEl.className = docEl.className.replace(/(^|\s)no-touch(\s|$)/, ' touch ');
hasTouch = true;
@joonassandell
joonassandell / Random: Commands
Last active September 13, 2016 15:54
Random commands I usually forget
# Curl
**Test origin to a target**:
`curl -i -H "Origin: http://origindomain.com" targetdomain.com`
# SSH
**Show all added keys**:
`ssh-add -l`
@joonassandell
joonassandell / *nix: Commands
Last active November 3, 2016 09:13
Random Debian etc. commands I usually forget
**Ubuntu version**:
`lsb_release -a`
**Amount of ram**:
`lshw -C memory`
**Switch to superuser**:
`sudo su`
**Show linux headers**:
@joonassandell
joonassandell / *nix: Install composer to Jelastic etc.
Last active November 3, 2016 09:13
Install Composer to *nix systems (Jelastic, Apache, Nginx)
# Install Composer to Jelastic etc.
If the environment is new, you'll need composer.
1. `cd /var/www/webroot`
2. `curl -sS https://getcomposer.org/installer | php`
3. `mkdir ~/bin`
4. `mv ./composer.phar ~/bin/composer`
After installing, you can add composer to your PATH.
@joonassandell
joonassandell / Apache: Commands
Last active November 3, 2016 09:14
Random Apache/MySQL commands I usually forget
**Update latest settings and install apache w/ MySQL**:
```
apt-get update
apt-get install apache2
apt-get install php5-mysql
apt-get install php5
apt-get install php5-gd # (if gd needed)
apt-get install mysql-server
```