Skip to content

Instantly share code, notes, and snippets.

View allaniftrue's full-sized avatar

Tux allaniftrue

  • 20:07 (UTC +08:00)
View GitHub Profile
@allaniftrue
allaniftrue / create-users-table.js
Created August 9, 2018 17:25
A sample sequelize migration with default value for timestamps
"use strict";
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable("users", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
@allaniftrue
allaniftrue / 422.js
Created May 27, 2018 12:26
Snippet to capture laravel's 422 error
axios.post('/login', {
email: self.email,
password: self.password
})
.then(response => {
// successful login
}, error => {
const responseData = error.response.data;
const firstErrorKey = Object.keys(responseData.errors);
@allaniftrue
allaniftrue / mysql_backup.sh
Created February 27, 2018 14:24
A simple mysql backup script with send
#!/bin/bash
# This is where the backup gets emailed too
[email protected]
DATE=`date`
DATABASEUSER=root
DATABASEPASS=secret
DATABASENAME=test
PREFIX=topup_
@allaniftrue
allaniftrue / eloquent_sql_logging.php
Created February 19, 2018 10:47
How to log eloquent queries when you are using the the illuminate package outside of laravel.
<?php
$capsule = \Illuminate\Database\Capsule\Manager::connection();
$test = \App\Test::where('id', 1)->get();
error_log('SQL: ' . print_r($capsule->getQueryLog(), true));
//without the bindings
@allaniftrue
allaniftrue / laradock_aerospike.txt
Last active January 16, 2018 03:25
Fixing Laradock's `unable to load dynamic library aerospike` error
- Modify laradock's /workspace/Dockerfile-<php version>
- Update the snippet below (ref: https://github.com/laradock/laradock/commit/3a5100097ab0eb9144c385a1e516ac9a54077bdf)
RUN if [ ${INSTALL_AEROSPIKE} = false ]; then \
rm /etc/php/5.6/cli/conf.d/aerospike.ini \
;fi
change to
This file has been truncated, but you can view the full file.
## Script generated 11/26/2017 at 05:48:57 (19997 entries) for 4.605 sec.
##
## Hosts list sources:
## > https://cdn.rawgit.com/tarampampam/static/master/hosts/block_shit.txt
## > https://adaway.org/hosts.txt
## > http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext
## > http://someonewhocares.org/hosts/hosts
## > http://getadhell.com/standard-package.txt
## > https://www.micu.eu/adblock/youtube_complete.txt
## > https://www.micu.eu/adblock/ad_list.txt
@allaniftrue
allaniftrue / mikrotik.rsc
Created November 24, 2017 14:26
A sample mikrotik automation script
# nov/24/2017 22:10:36 by RouterOS 6.40.5
# software id = XXXXXX
#
# model = 951G-2HnD
# serial number = XXXXX
/interface bridge
add fast-forward=no name=Bridge-LAN&WAN
add admin-mac=6C:3B:6B:91:F5:3F auto-mac=no fast-forward=no name=bridgeLocal
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-b/g/n country=singapore disabled=no frequency=auto mode=ap-bridge ssid="John 3:16" wireless-protocol=802.11
@allaniftrue
allaniftrue / mysql_backup.sh
Last active January 29, 2018 23:12
FreeBSD script to automate MySQL backup and send file to email
#!/bin/bash
# Credentials
DATE=`date`
DATABASEUSER=root
DATABASEPASS=secret
DATABASENAME=test
[email protected]
# For filename purpose
@allaniftrue
allaniftrue / app.js
Created October 30, 2017 23:32
Capture laravel error on axios promise
let key = Object.keys(error.response.data)[0];
if(error.response.status === 422) {
swal('Oh snap!', error.response.data[key][0], "error");
} else {
swal('Error!', error.message, "error");
}
@allaniftrue
allaniftrue / Component.vue
Created October 27, 2017 23:34
Adding Vuejs Props: Passing A String Value
<template>
{{text}}
</template>
<script>
export default {
props: ['text']
}
</script>