Skip to content

Instantly share code, notes, and snippets.

View r17x's full-sized avatar
🤘
REconciling...

RiN r17x

🤘
REconciling...
View GitHub Profile
@r17x
r17x / wp-featured-image-upload-for-front-end.php
Created February 21, 2018 03:48 — forked from juyal-ahmed/wp-featured-image-upload-for-front-end.php
Upload featured image on custom post from WordPress front-end
@r17x
r17x / gist:2401a3149dd04e1d10beab720c49b353
Created February 21, 2018 03:48 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@r17x
r17x / unregister.js
Created February 28, 2018 11:36 — forked from inian/unregister.js
Unregister all SW registrations
try {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
registrations.forEach(function(registration) {
console.log('removing registration', registration);
registration.unregister();
})
})
}
catch (e) {
console.log('failed to unregister all service workers', e);
#Example Problem:
Expression #9 of SELECT list is not in GROUP BY clause and contains nonaggregated column 
'table.column' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
#Solved With:
use your_db;
SET sql_mode = '' ;
#or
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
#or config mysql service 
@r17x
r17x / sandiJson.php
Last active March 10, 2018 11:20
Simple Arrray Map PHP
<?php
/**
* saya memiliki contoh JSON dalam bentuk string
*/
$stringJson = '{"message":[{"id":"23","description":"AXIS 5000","code":"AX5","code_alias":"AH5","substitute":"1","price":"5419","profit_max":"160","h2h":"5419","h2h_lock":"0","h2h_max":"100","price_host":"5319","nominal":"5000","operator":"AXIS","operator_sub":"AX","supplier":"lumbung","publish":"1","status":"normal","block":"0","date_update":"2016-01-26 13:35:02","provider":"AXIS","provider_sub":"REGULER"},{"id":"28","description":"AXIS 10000","code":"AX10","code_alias":"AH10","substitute":"1","price":"10419","profit_max":"160","h2h":"10419","h2h_lock":"0","h2h_max":"100","price_host":"10319","nominal":"10000","operator":"AXIS","operator_sub":"AX","supplier":"lumbung","publish":"1","status":"normal","block":"0","date_update":"2016-02-09 07:20:02","provider":"AXIS","provider_sub":"REGULER"}]}';
/**
* Disini Saya merubah dari format string Json ke
@r17x
r17x / with-virtualenv.sh
Last active March 10, 2018 12:30
Chatbot Hangout KPM #1
$ sudo apt-get install python-virtualenv python-pip
$ virtualenv chatBot # chatBot <-- Nama Virtual Env & Boleh anda ganti
$ cd chatBot && source bin/activate
$ # disebelah kanan (chatbot) menandakan virtualenv telah aktiv
(chatbot)$ git clone https://github.com/dev-makassar/ChatBot.git && cd ChatBot
(chatbot)$ pip install -r requirements.txt
(chatbot)$ # Dependencies atau library yang dibutuhkan selesai di tambahkan ke virtualenv
$ git clone https://github.com/dev-makassar/ChatBot.git && cd ChatBot
$ pip install -r requirements.txt --user
$ # Dependencies atau library yang dibutuhkan selesai di tambahkan ke virtualenv
from flask import Flask
# deklarasi variabel app untuk menampung atau membangun Object Class Framework Flask
app = Flask(__name__)
# deklarasi variable config untuk mengatur konfigurasi dasar dari flask
# port untuk port app flask saat di jalankan
# debug untuk mengaktivkan mode debug jika bernilai benar (True)
config = {
'port': 5000,
from flask import Flask, request
# jangan lupa tambahkan request pada import Flask Library
....
VerifyToken='V3rifyT0k3N'
@app.route('/webhook', methods=['GET'])
def webhook():
if request.method == 'GET':
if request.args.get("hub.verify_token") == VerifyToken:
return request.args.get("hub.challenge")
else:
@r17x
r17x / rabbitmq.txt
Created March 22, 2018 05:55 — forked from sdieunidou/rabbitmq.txt
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"