Skip to content

Instantly share code, notes, and snippets.

View aphe's full-sized avatar
👋
Oh, Hi there!

Afriyandi Setiawan aphe

👋
Oh, Hi there!
View GitHub Profile
@aphe
aphe / cell.swift
Created July 12, 2019 09:05
infinite scroll
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return (self.setHomeBanners?.count ?? 0) * 2
}
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
var offset = collectionView.contentOffset
// horizontal
// let height = collectionView.contentSize.height
// if offset.y < height/4 {
// offset.y += height/2
@aphe
aphe / main.py
Last active May 7, 2019 01:49
get the message from mailgun hook and post it to slack and upload the attachment to cloudinary
slack_hook = 'slack_hook'
cloud_name = 'cloudinary_name'
cloud_key = 'cloudinary_api_key'
cloud_secret = 'cloudinary_secret_key'
def mail2slack(request):
import cloudinary
hookDict = request.form.to_dict()
cloudinary.config(

Keybase proof

I hereby claim:

  • I am aphe on github.
  • I am aphe (https://keybase.io/aphe) on keybase.
  • I have a public key ASC1EmMdezeXR3nu7WD5o31DTKY9nu2nC7SGTewkWcEhBgo

To claim this, I am signing this object:

@aphe
aphe / TableView.swift
Last active November 28, 2018 03:19
[TableView.playground] TableView on playground
import UIKit
import PlaygroundSupport
var str = "Hello, playground"
struct Meal {
var name: String
var food: [Food]
}
@aphe
aphe / gitUnstash
Created November 13, 2018 03:00
Unstash specific file
git checkout 'stash@{#indexStash}' -- filename
struct Meta {
var page: String?
var next: String?
var keyword: String?
var row: Int?
}
struct Card {
var coveer: Int?
var card: [CardInside]?
struct iOSVersion {
static func IS_EQUAL_TO(version: String) -> Bool{
return UIDevice.currentDevice().systemVersion.compare(version, options: NSStringCompareOptions.NumericSearch) == NSComparisonResult.OrderedSame
}
static func IS_GREATER_THAN(version: String) -> Bool{
return UIDevice.currentDevice().systemVersion.compare(version, options: NSStringCompareOptions.NumericSearch) == NSComparisonResult.OrderedDescending
}
static func IS_GREATER_THAN_OR_EQUAL_TO(version: String) -> Bool{
return UIDevice.currentDevice().systemVersion.compare(version, options: NSStringCompareOptions.NumericSearch) == NSComparisonResult.OrderedAscending
}
{
"name": "OpenCV",
"version": "2.4.9",
"summary": "OpenCV (Computer Vision) for iOS.",
"homepage": "http://opencv.org",
"description": "OpenCV: open source computer vision library\n\n Homepage: http://opencv.org\n Online docs: http://docs.opencv.org\n Q&A forum: http://answers.opencv.org\n Dev zone: http://code.opencv.org",
"license": {
"type": "3-clause BSD",
"text": "By downloading, copying, installing or using the software you agree to this license.\nIf you do not agree to this license, do not download, install,\ncopy or use the software.\n\n\n License Agreement\n For Open Source Computer Vision Library\n (3-clause BSD License)\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n * Redistribution's of source code must retain the above copyright notice,\n this list of conditions and the following disclaimer.\n\n * Redistribution's in binary form must reproduce

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.

This write-up owes a great deal to dscape's Node.js Deployments with Docker, Dokku, & Digital Ocean, the dokku project itself, and the fine folks working on dokku's issues. I took dscape's article as a starting point when trying this out but found some details lacking so I documented my own process for getting dokku up and running.

1. Get a domain

@aphe
aphe / brute.py
Created March 1, 2015 05:33
simple brute
for lol in itertools.product("0123456789abcdefghijklmnopqrstuvwxyz",repeat=6):
print("".join(lol))