Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@remoharsono
remoharsono / es6-module.html
Last active October 28, 2019 06:01
Tutorial Penggunaan ES6 Module, Part 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>.</title>
<script type="module" src="main.js"></script>
</head>
<body>
</body>
@remoharsono
remoharsono / ldap_search.php
Created October 21, 2019 07:02
My LDAP Search Implementing Pagination
<?php
define("LDAP_HOST","mycompany.co.id");
define("LDAP_PORT", "389");
define("BASE_DN", "dc=mycompany,dc=co,dc=id");
define("PAGE_SIZE", 100); // limit
define("LDAP_USER", "username@mycompany.co.id");
define("LDAP_PASSWORD", 'secret');
@remoharsono
remoharsono / ldap.php
Last active October 18, 2019 06:49
PHP: Login to LDAP
define("LDAP_HOST", "ldap://mydomain.co.id:389");
define("LDAP_VERSION", 3);
function authLDAP($ldap_username, $ldap_password) {
$ret = array();
if ($ldap_connection = ldap_connect(LDAP_HOST)) {
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, LDAP_VERSION);
if ($ldap_bind = @ldap_bind($ldap_connection, $ldap_username, $ldap_password)) {
$ret['result'] = 'OK';
@remoharsono
remoharsono / gist:ec3631383481920aa458762b7caba19c
Created August 13, 2019 04:14 — forked from niczak/gist:2003485
PHP/SOAP and Microsoft Exchange
<?php
/*
test.php
Proof of concept testing to see if we can get
PHP/SOAP talking to EWS. Thanks to Thomas Rabaix
for his documentation on NTLM auth in SOAP and to
Erik Cederstrand for his article on SOAP/Exchange.
@remoharsono
remoharsono / method_chaining.php
Created August 8, 2019 13:25
a simple sample of PHP Method Chaining
<?php
// taken from: https://stackoverflow.com/questions/3724112/php-method-chaining
class DBManager
{
private $selectables = array();
private $table;
private $whereClause;
private $limit;
public function select() {
<!DOCTYPE html>
<html>
<head><title>.</title>
<meta charset="UTF-8">
</head>
<body>
<input type="file" name="filename" id="fileName">
<input type="button" value="Upload" onclick="btnUpload_click()">
@remoharsono
remoharsono / curl.md
Created July 17, 2019 03:38 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

function sanitize_file_name( $filename ) {
$filename_raw = $filename;
$special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', chr( 0 ) );
/**
* Filters the list of characters to remove from a filename.
*
* @since 2.8.0
*
* @param array $special_chars Characters to remove.
* @param string $filename_raw Filename as it was passed into sanitize_file_name().
@remoharsono
remoharsono / instagram_mine.py
Created April 18, 2019 02:17 — forked from rubinovitz/instagram_mine.py
A python script for downloading all of the instagram photos of a certain hashtag I wrote for a friend in 20 minutes (forgive sloppiness). Warning: you're only allowed 30 API requests an hour. Requires your own access token set as environment variable "access_token".
from datetime import datetime
import urllib2
import urllib
import json
import os
def ajaxRequest(url=None):
"""
Makes an ajax get request.
url - endpoint(string)
@remoharsono
remoharsono / supervisord.conf
Created March 20, 2019 08:01 — forked from lenciel/supervisord.conf
supervisor configuration file for sentry
;Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;
; Put this file in /etc/supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)