Skip to content

Instantly share code, notes, and snippets.

@liunian
liunian / gist:9338301
Last active April 26, 2024 03:30
Human Readable File Size with PHP
<?php
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
echo human_filesize(filesize('example.zip'));
@jveldboom
jveldboom / readme.md
Last active March 18, 2018 20:37
Unbuntu 14.04 Vagrant LEMP + Laravel
### Download setup Ubuntu 14.04 box
```
// from local directory
vagrant init chef/ubuntu-14.04
```
### Setup Vagrantfile
```
# -*- mode: ruby -*-
# vi: set ft=ruby :
@antoniwan
antoniwan / .zshrc
Last active June 3, 2017 13:50
.zshrc - Oh-my-zsh settings
export ZSH=/Users/antoniwan/.oh-my-zsh
ZSH_THEME="robbyrussell"
ENABLE_CORRECTION="true"
COMPLETION_WAITING_DOTS="true"
plugins=(git)
# user configuration
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
export PATH="$PATH:~/.composer/vendor/bin"
export PATH="$PATH:/Users/antoniwan/.composer/vendor/bin"
@varver
varver / cookie_jar_golang.go
Last active June 7, 2022 13:04
Login to a website with this golang code using persistent cookies or cookie jar .
@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@JeffreyWay
JeffreyWay / .bash_profile
Created July 31, 2015 19:20
Prettier git logs
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@devthue
devthue / git-ignore-local.md
Created August 12, 2016 04:18
Git ignore files only locally

Sources: http://stackoverflow.com/questions/1753070/git-ignore-files-only-locally

The .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

git update-index --assume-unchanged [<file>...]

Note on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.

@JacobBennett
JacobBennett / ReadMe.MD
Last active September 30, 2023 09:14
Loading Laravel Sentry only for production

Loading Laravel Sentry package only for production

In the case that you don't want development errors making their way to Sentry for error tracking, you can use the code below to ensure that Sentry will only record exceptions when in production.

First, instead of loading the SentryLaravelServiceProvider in the config/app.php providers array, we will load it in our App/Providers/AppServiceProvider.php. This allows us to check the environment before loading the appropriate service providers.

Seconly, in our App/Exceptions/Handler.php we again check for the production environment before trying to capture the exception using Sentry. This second step prevents Sentry from trying to catch an exception when it isn't bound in the container.

@JacobBennett
JacobBennett / blog.md
Last active June 7, 2024 17:42
Clean up your Vue modules with ES6 Arrow Functions

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.

<script>

// require vue-resource...

new Vue({