Skip to content

Instantly share code, notes, and snippets.

View agusputra's full-sized avatar
🏠
Working from home

Agus Syahputra agusputra

🏠
Working from home
View GitHub Profile

reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP" /s /v version | findstr /i version | sort /+26 /r

@agusputra
agusputra / Dependency-Injection-Example.cs
Last active January 28, 2022 23:23
IoC and Dependency Injection Example
class Program
{
interface IPrinter
{
void Print();
}
class InjectPrinter : IPrinter
{
public void Print()
@agusputra
agusputra / parseQueryString.js
Last active September 9, 2020 05:04
parseQueryString
export function parseQueryString() {
const qs = decodeURIComponent(window.location.search.substring(1)).split('&');
const result = {};
for (const i in qs) {
if (Object.prototype.hasOwnProperty.call(qs, i)) {
const keyValue = qs[i].split('=');
result[keyValue[0]] = keyValue[1];
}
<?php
function flattenArray($source, $key = null)
{
$result = array();
if ($key) {
array_walk_recursive($source, function ($v, $k) use ($key, &$result) {
if ($k === $key) {
$result[] = $v;
@agusputra
agusputra / lightbox.html
Created November 6, 2015 07:44
Simple lightbox example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.lightbox {
position: fixed;
/* Remove default browser outline */
outline: none;
let lastScrollTop = 0
$(window).scroll(function(event) {
const st = $(this).scrollTop()
if (st > lastScrollTop) {
// downscroll code
}
else {
// upscroll code
@agusputra
agusputra / Load_JQuery_And_Execute_Handler_After_Detected.js
Last active February 12, 2016 04:29
Load_JQuery_And_Execute_Handler_After_Detected
(function () {
if (window.jQuery) {
console.log('jQuery already loaded');
} else {
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', 'https://code.jquery.com/jquery.min.js');
document.body.appendChild(s);
console.log('jQuery has been attached');
}
Helper.php
===
<?php
class Helper
{
private static $instance;
public static $alert;
public function __construct()
@agusputra
agusputra / utils.php
Last active November 3, 2019 09:42
utils
<?php
class Request
{
public static function get($input, $cleaning = true)
{
// global $db;
$input = isset($_GET[$input]) ? $_GET[$input] : null;
// if ($input && gettype($input) !== 'array') {
// $input = $cleaning ? @$db->clean($input) : $input;
@agusputra
agusputra / accessObject.js
Last active May 13, 2016 00:54
Access or Compose object using string literal. ex: '1.2.3' => {"1": {"2": {"3": "0"}}}
'use strict';
const state = {
a: {
aa: {
aaa: 'AAA'
},
ab: {
aab: 'AAB'
}