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 / 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;
}
@olssonm
olssonm / macos-disable-resize
Last active April 30, 2024 12:23
Disable resizing of the macOS dock
defaults write com.apple.dock size-immutable -bool true; killall Dock
@olssonm
olssonm / sv-locale.sh
Last active December 4, 2022 17:58
Install Swedish language pack on Ubuntu
#Update package lists
sudo apt-get update
#Fetch language pack
sudo apt-get install language-pack-sv
#Check available languages, sv_SE.utf8
locale -a
#Generate locale
@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 / 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 / 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 / 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 / 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 / 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 / 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));