Skip to content

Instantly share code, notes, and snippets.

View slaveofcode's full-sized avatar
🎯
Debugging

Aditya Kresna slaveofcode

🎯
Debugging
View GitHub Profile
@slaveofcode
slaveofcode / QuerystringReplacement.js
Created May 19, 2016 06:59
Javascript Querystring Replacement
function queryStringUrlReplacement(url, param, value)
{
var re = new RegExp("[\\?&]" + param + "=([^&#]*)"), match = re.exec(url), delimiter, newString;
if (match === null) {
// append new param
var hasQuestionMark = /\?/.test(url);
delimiter = hasQuestionMark ? "&" : "?";
newString = url + delimiter + param + "=" + value;
@slaveofcode
slaveofcode / CORS-Nginx-Configuration.conf
Last active June 10, 2016 17:23
Enables CORS on Nginx Config
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
@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 / 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 / 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;
@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