Skip to content

Instantly share code, notes, and snippets.

View rifki's full-sized avatar
Working from home

rifki rifki

Working from home
View GitHub Profile
@rifki
rifki / bootstrap.php
Last active August 29, 2015 14:24
Couchdb, Memcache and PHP example
<?php
// lib php couchdb
require 'lib/couch.php';
require 'lib/couchClient.php';
require 'lib/couchDocument.php';
// config couchdb
define('COUCH_DSN', 'http://127.0.0.1:5984');
define('COUCH_DBNAME', 'testcase_blog');
// config memcache
{
"_id": "_design/get_blog_posts",
"language": "javascript",
"views": {
"all": {
"map": "function(doc) { emit(doc._id, doc); } "
},
"by_date": {
"map": "function(doc) { if (doc) { emit(doc.created_at, null); } }"
}
@rifki
rifki / has_duplicate.php
Created September 30, 2015 17:52
check is duplicate value in array - php
<?php
//check duplicate entry
$arr = [1,2,3,3,3,4,4,5,6,7,8,9,10,10,10,10,10,20,20];
// solution 1
function has_duplicate1($array) {
$dupl = [];
$space = php_sapi_name() == 'cli' ? "\n" : "<br>";
foreach(array_count_values($array) as $value => $count) {
if ($count > 1) {
@rifki
rifki / host
Last active January 22, 2022 17:27
Blokir Iklan Speedy dari situs v3.mercusuar.uzone.id
Ini adalah cara untuk memblockir iklan speedy jika kita salah ketik url website,
lalu telkom akan mengarahkan ke situs http://v3.mercusuar.uzone.id/?url=kamusalahketikurl.com
# Windows User
=====================
1. Edit file hosts C:\Windows\System32\Drivers\etc\hosts menggunakan notepad
2. Tambahkan seperti berikut:
127.0.0.1 v3.mercusuar.uzone.id # block telkom redirect
127.0.0.1 118.97.116.10
127.0.0.1 mercusuar.uzone.id
@rifki
rifki / feed.php
Last active April 2, 2016 03:22
Append XML File
<?php
// format xml
/*
<products>
<product>
....
....
<product>
</products>
*/
@rifki
rifki / pagespeed.conf
Last active April 3, 2016 02:12
Google pagespeed module Apache
ModPagespeedDomain http://local.dev.com
ModPagespeedDisallow */admin/*
ModPagespeedMapOriginDomain http://localhost http://local.dev.com
ModPagespeedStatistics on
ModPagespeedStatisticsLogging on
ModPagespeedEnableFilters prioritize_critical_css
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters recompress_png
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
@rifki
rifki / vimrc
Last active April 4, 2016 02:32
simple .vimrc for Tab vi/vim
$ vim ~/.vimrc
set number
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
@rifki
rifki / swap
Created April 11, 2016 15:28
force clean swap and add swap
$ sudo swapoff -a
$ sudo swapon -a
$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=2048
$ sudo /sbin/mkswap /var/swap.1
$ sudo /sbin/swapon /var/swap.1
@rifki
rifki / gist:0c337dbaba9b320f3032aa0b79358629
Created April 11, 2016 15:31
proxy module .htaccess amazon s3 to cloudfront
.....
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
ProxyRequests off
ProxyPass /feed/ http://abcdefg.cloudfront.net/feed/
@rifki
rifki / varnish
Created April 11, 2016 15:33
varnish
backend default {
.host = "local.app.com";
.port = "8080";
}
sub vcl_recv {
if (req.request == "GET" && req.url ~ "\.(gif|jpg|jpeg|png|ico)$") {
return(lookup);
}
else {