Skip to content

Instantly share code, notes, and snippets.

View vianhanif's full-sized avatar
🚀
{do} {things}

Alvian Rahman Hanif vianhanif

🚀
{do} {things}
  • Depok, Indonesia
View GitHub Profile
@vianhanif
vianhanif / file.go
Created November 20, 2019 21:05
sample-go.go
package main
import (
"fmt"
"regexp"
"strings"
)
func main() {
//mat3 := regexp.MustCompile(`[a-zA-Z0-9]`)
package handlers_test
import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"reflect"
@vianhanif
vianhanif / file.go
Created September 29, 2019 14:32
sample
// GroupByUserAndType : grouping cashback by userId and type
func (service *App) GroupByUserAndType(ctx context.Context, params ...QueryFilter) ([]*SumCashback, error) {
queryable, ok := data.QueryableFromContext(ctx)
if !ok {
queryable = service.queryable
}
where, args := BuildFilter(params...)
statement := fmt.Sprintf(`
SELECT "userId", SUM(amount) AS "amount", "type"
FROM "%s" %s GROUP BY "userId", "type";
@vianhanif
vianhanif / Dockerfile
Last active October 24, 2024 19:21
Golang (chromedp) + Xvfb + Chrome + Docker
FROM golang:1.11-alpine as builder
WORKDIR /myapp
COPY go.mod .
COPY go.sum .
RUN apk add --no-cache ca-certificates git
# Get dependancies - will also be cached if we won't change mod/sum
RUN go mod download
@vianhanif
vianhanif / package.json
Last active September 26, 2017 09:39
sample server node.js
{
"name": "sha224_tester",
"version": "1.0.0",
"description": "",
"author": "Alvian Rahman Hanif",
"private": true,
"scripts": {
"postinstall": "npm install express"
}
}
@vianhanif
vianhanif / railFence.js
Last active September 27, 2017 05:47
Rail Fence Cipher Encryption & Decryption
const key = 3
const offset = 2
// setup arrays as mush as key in one table
const setupTable = (table, key) => {
for (let i = 0; i < key; i++) {
table.push([])
}
}
@vianhanif
vianhanif / scytale.js
Last active March 23, 2024 13:47
Scytale Encryption & Decryption
const column = 5
export const encrypt = (text) => {
let token = text.split('')
let rows = token.length / column
let result = ''
for (let i = 0; i < column; i++) {
for (let j = 0; j < rows; j++) {
if ((j * column) + i < (token.length)) {
@vianhanif
vianhanif / jefferson.js
Last active September 27, 2017 03:55
Jefferson Encryption & Decryption
const possibleTokens = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_ +-=[]{}|;\'\\:",./<>?'
const shifter = 5
// setup letters into a one line for each possible disk
const data = () => {
let val = []
possibleTokens.split('').forEach((letter, index) => {
val.push(letter)
})
return val
}
ruby -rbundler/inline -e "gemfile(true) do; source 'https://rubygems.org/'; gem 'rails', '5.1.0.beta1'; end"
@vianhanif
vianhanif / data.js
Last active February 28, 2017 17:48
const data = {
navbar: {
icon: 'assets/icon.png',
navs: ['Beranda','Tentang Kami', 'Pengumuman', 'Galeri', 'Videos', 'Kontak Kami']
},
video: [
{
url: "https://www.youtube.com/embed/wJAGy08EbJA"
},
{