Skip to content

Instantly share code, notes, and snippets.

View xtrasmal's full-sized avatar
🟢
--- 200 OK

Xander xtrasmal

🟢
--- 200 OK
View GitHub Profile
@xtrasmal
xtrasmal / hashids-route-binding.php
Created May 12, 2017 23:37
Playing with route bindings and hashids to get a backwards compatible solution. It will not decode if it can't.
<?php
// create a route like this
$this->route->get('projects/{id}', 'ProjectsController@show');
// Put this in your provider
// It will check if it can decode, else it will just return what was put in the url
$this->route->bind('id', function ($id) {
return (new Hashids())->decode($id)[0] ?? $id;
@xtrasmal
xtrasmal / app.js
Created October 29, 2016 19:11
Vue 2.0 start
import Vue from 'vue';
import store from './store';
// Load root component
if(elementIsFound("application")) {
new Vue({
store,
name: 'Your application',
components: {
pages: require('./components/pages')
@xtrasmal
xtrasmal / dirsize
Created October 6, 2016 07:47
osx commandline directory size
dirsize () {
du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
}
@xtrasmal
xtrasmal / mysql-encrypt.sql
Last active September 17, 2016 20:54
AES encrypt mysql fields. Needs VARBINARY(112) columntypes
INSERT into encrypted_data (encrypted) VALUES (AES_ENCRYPT('let us hide this stuff', 'secretkey'));
SELECT AES_DECRYPT(encrypted, 'secretkey') from encrypted_data WHERE AES_DECRYPT(encrypted, 'secretkey') LIKE '%hide%';
@mixin aspect-ratio($width, $height) {
position: relative;
&:before{
display: block;
content: " ";
width: 100%;
padding-top: ($height / $width) * 100%;
}
> .content {
@xtrasmal
xtrasmal / flasher.js
Created March 21, 2016 22:51
Vue Flasher with alertify.js
import alertify from 'alertify.js';
const Flasher = {
success(thing, action) {
alertify.logPosition("top right");
alertify.success(`Het ${thing} is ${action}.`);
},
@xtrasmal
xtrasmal / config.js
Created March 21, 2016 22:50
Vue notifier
var Config = { /* How long the notification stays visible */
default_timeout: 5000,
/* container for the notifications */
container: document.createElement('div'),
/* container styles for notifications */
container_styles: {
position: "fixed",
zIndex: 99999,
right: "12px",
top: "12px"
@xtrasmal
xtrasmal / donut.js
Created March 21, 2016 22:45
WIP - Vue GraphMixin with c3
/**
* Donut Graph
*/
var GraphMixin = require('./graph-mixin');
var Donut = {
mixins: [GraphMixin],
ready: function (){
this.create();
},
data: function() {
@xtrasmal
xtrasmal / readme.txt
Created March 14, 2016 08:52
Everybody poops blood
==========================================================================
______
\ \. EVERYBODY POOPS BLOOD
|`\_____\
|` | | DON'T BE A WUSS JUST REACH IN THERE
| | | AND WOLF IT DOWN LIKE A MAN
__-====-__ _| | |
(~< >~> \ | | LOOK THERE'S ONE THING I'VE LEARNED
!~~-====-~~/----`+----/ AND THAT'S ONCE YOUR FINGERPRINTS ARE
@xtrasmal
xtrasmal / package.json
Last active June 7, 2016 11:30
Npm all the things
{
"name": "npm-all-the-things",
"version": "0.0.7",
"description": "",
"author": "X.Smalbil",
"license": "DBAD",
"main": "index.js",
"scripts": {
"build": "npm run build-js & npm run build-sass & npm run build-images",
"build-images": "imagemin './assets/images/*' './assets/build/images/*' -p",