Skip to content

Instantly share code, notes, and snippets.

View slaveofcode's full-sized avatar
🎯
Debugging

Aditya Kresna Permana slaveofcode

🎯
Debugging
View GitHub Profile
@slaveofcode
slaveofcode / eloquent-cheatsheet.php
Created May 30, 2016 07:55 — forked from hassansin/eloquent-cheatsheet.php
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@slaveofcode
slaveofcode / forms.py
Created June 14, 2016 03:13 — forked from maraujop/forms.py
django-crispy-forms bootstrap form example
# -*- coding: utf-8 -*-
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions
class MessageForm(forms.Form):
text_input = forms.CharField()
MySQL Cheat Sheet
Indexes:
- UNIQUE
- INDEX
- PRIMARY KEY
- FULLTEXT (MyISAM engine only)
SHOW ENGINES -> shows available storage engines and default storage engine
@slaveofcode
slaveofcode / SimpleStore.js
Created June 25, 2016 09:49 — forked from ksafranski/SimpleStore.js
Simple localStorage function with Cookie fallback for older browsers.
/**
* Simple localStorage with Cookie Fallback
* v.1.0.0
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store('my_key', 'some_value');
*
* Retrieve:
@slaveofcode
slaveofcode / nginx_prerender_html.conf
Created July 18, 2016 07:35 — forked from Stanback/nginx.conf
Example Nginx configuration for serving pre-rendered HTML from Javascript pages/apps using the Prerender Service (https://github.com/collectiveip/prerender).Instead of using try_files (which can cause unnecessary overhead on busy servers), you could check $uri for specific file extensions and set $prerender appropriately.
server {
listen 80;
listen [::]:80;
server_name yourserver.com;
root /path/to/your/htdocs;
error_page 404 /404.html
index index.html;
<!-- SEO / Google -->
<meta name="author" content="Author name here....">
<meta name="description" content="Description text here.....">
<link rel="canonical" href="URL here...">
<!-- Social: Twitter -->
<!-- After inserting META need to validate at https://dev.twitter.com/docs/cards/validation/validator -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@8bit_code">
<meta name="twitter:creator" content="8bit_code">
@slaveofcode
slaveofcode / article.html
Created August 6, 2016 08:11 — forked from letanure/article.html
Social Media Tag Template
<!-- Place this data between the <head> tags of your website -->
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. No longer than 155 characters." />
<!-- Twitter Card data -->
<meta name="twitter:card" value="summary">
<!-- Open Graph data -->
<meta property="og:title" content="Title Here" />
<meta property="og:type" content="article" />

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@slaveofcode
slaveofcode / Install-php7.md
Created October 17, 2016 04:47 — forked from hollodotme/Install-php7.md
Installing php7-fpm with phpredis and xdebug extension on Ubuntu 14.04

Install php7.0-fpm

# remove php5 modules
apt-get autoremove --purge php5-*
# add php-7.0 source list by [Ondřej Surý](https://github.com/oerdnj)
add-apt-repository ppa:ondrej/php
# Update index
apt-get update
# Install php7.0-fpm with needed extensions
@slaveofcode
slaveofcode / users.sh
Created October 18, 2016 16:37
Basic user operations on a Linux box
# add user to linux and create home directory (remember to change SHELL in /etc/passwd)
useradd -m USER
# set password
passwd USER
# add to extra groups, no change on primary
usermod -a -G GROUP1,GROUP2 USER
# list groups a user belongs to