Skip to content

Instantly share code, notes, and snippets.

View olssonm's full-sized avatar
🖥️
Working on some cool stuff

Marcus Olsson olssonm

🖥️
Working on some cool stuff
View GitHub Profile
@olssonm
olssonm / numbers-csv-parse.php
Created November 7, 2019 07:54
Quick way to parse a CSV-file exported from Apple Numbers (using default UTF-8 formatting).
$data = array_map(function($v) {
return str_getcsv($v, ";");
}, file($file));
@olssonm
olssonm / ngrok.sh
Created September 5, 2019 12:53
Route ngrok to custom local host
./ngrok http 192.168.10.10:80 --host-header=SITE
@olssonm
olssonm / import.php
Created November 6, 2018 07:01
Import a SQL-file/dump in Laravel
<?php
use DB;
DB::unprepared(file_get_contents(storage_path('file.sql')));
@olssonm
olssonm / allowPaste.js
Created September 21, 2018 13:20
Enable paste on sites that blocks it
var allowPaste = function(e){
e.stopImmediatePropagation();
return true;
};
document.addEventListener('paste', allowPaste, true);
@olssonm
olssonm / composer.json
Created May 29, 2018 05:31
Load local packages via composer (for Laravel among others)
"require": {
"my/package": "dev-master",
},
"repositories": [
{
"type": "path",
"url": "../packages/my/package",
"options": {
"symlink": true
}
@olssonm
olssonm / git restore
Created January 26, 2018 07:24
Restore files to a previous state in git
# Via https://stackoverflow.com/questions/215718/reset-or-revert-a-specific-file-to-a-specific-revision-using-git
git checkout c5f567 -- file1/to/restore file2/to/restore
# ~1 denotes commits before hash
git checkout c5f567~1 -- file1/to/restore file2/to/restore
@olssonm
olssonm / newline.py
Created January 17, 2018 06:52
Fix for corrupted files in /var/lib/dpkg/info/ – every and all credit to this forum post: https://ubuntuforums.org/showthread.php?t=1319791
#!/usr/bin/python
# 8th November, 2009
# update manager failed, giving me the error:
# 'files list file for package 'xxx' is missing final newline' for every package.
# some Googling revealed that this problem was due to corrupt files(s) in /var/lib/dpkg/info/
# looping though those files revealed that some did not have a final new line
# this script will resolve that problem by appending a newline to all files that are missing it
# NOTE: you will need to run this script as root, e.g. sudo python newline_fixer.py
@olssonm
olssonm / site.conf
Created August 15, 2017 11:17
Nginx browser cache
# BROWSER CACHE
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|xml|otf|ttf|eot|woff|woff2|svg|ico)$ {
expires 365d;
}

Keybase proof

I hereby claim:

  • I am olssonm on github.
  • I am olssonm (https://keybase.io/olssonm) on keybase.
  • I have a public key ASCzC811GvJdvWmN0-mAQKbO6LG3DHz0paOzwnfef4rVfwo

To claim this, I am signing this object:

@olssonm
olssonm / homestead56.yaml
Created July 6, 2017 13:13
Laravel Homestead
---
ip: "192.168.10.20"
version: 0.3.3
memory: 2048
cpus: 1
hostname: homestead56
name: homestead56
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys: