Skip to content

Instantly share code, notes, and snippets.

View putraxor's full-sized avatar
💭
I may be slow to respond.

Ardiansyah Putra putraxor

💭
I may be slow to respond.
View GitHub Profile
@putraxor
putraxor / analytic_wfm.py
Created April 18, 2020 06:32 — forked from sixtenbe/analytic_wfm.py
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@putraxor
putraxor / compressed_pickle.py
Created January 18, 2020 14:39 — forked from cwidmer/compressed_pickle.py
save/load compressed pickled objects in python
import cPickle
import bz2
def save(filename, myobj):
"""
save object to file using pickle
@param filename: name of destination file
@type filename: str
@putraxor
putraxor / macapp.go
Created June 24, 2019 10:08 — forked from mholt/macapp.go
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
@putraxor
putraxor / fade_route.dart
Created January 6, 2019 00:19 — forked from Norbert515/fade_route.dart
A route which fades the page in.
import 'package:flutter/material.dart';
/// Navigator.of(context).push(FadeRoute(
/// builder: (context) {
/// return NewPage();
/// }
/// ));
class FadeRoute extends PageRoute {
FadeRoute({@required this.builder});
@putraxor
putraxor / README.md
Created September 20, 2018 21:39 — forked from sma/README.md
This is an ad-hoc Java-to-Dart translator written in three days. This is version 2 which some bug fixes.

Java to Dart

This is an ad-hoc Java-to-Dart translator originally written on two (admittedly long) evenings.

See http://sma.github.io/stuff/java2dartweb/java2dartweb.html for a demo.

Note: It doesn't support the complete Java grammar specification and cannot translate everything. It only translates syntax and does not attempt to translate Java library classes and methods to Dart equivalents (with the exception of String.charAt and StringBuffer.append). You will have to make changes to the resulting Dart code. It does not support anonymous inner classes.

However, I was able to successfully convert a 7000+ line command line application with only minimal fixes in 30 minutes.

@putraxor
putraxor / Desktop.md
Created August 27, 2017 23:52 — forked from chinmaygarde/Desktop.md
Flutter Desktop Runner
  • You need to build the engine from source. Follow the steps at https://github.com/flutter/engine/blob/master/CONTRIBUTING.md#getting-the-code-and-configuring-your-environment
    • You can skip the forking step if you don’t think you will be contributing changes to the engine.
  • Once your environment is setup, build the engine in Release mode.
    • $ sky/tools/gn —release
    • $ ninja -C out/Release -j12
  • After the long build you will find a Mac application called SkyShell.app in out/Release. This is the generic Flutter application runner. It does not know anything about your dart project yet.
  • Create a sample dart project
    • $ flutter init -o mac_hello
  • From the command line, launch the SkyShell.app with command line flags telling it where your dart project resides and its package root. On my system I did this:
  • $ ./out/Release/SkyShell.app/Contents/MacOS/SkyShell PATH_TO_PROJECT/lib/main.dart --package-root=PATH_TO_PROJECT/packages
@putraxor
putraxor / DenomSuggestion.kt
Created July 30, 2017 03:35 — forked from esafirm/DenomSuggestion.kt
Given some amount, return possible values that constructed by particular denomination
val denom = arrayOf(1, 2, 5, 10, 20, 50, 100)
val amount = arrayOf(5, 11, 53, 122, 155, 157, 210, 200)
fun main(args: Array<String>) = amount.forEach { currentAmount ->
val suggestions = mutableListOf<Int>()
denom.forEach {
if (it >= currentAmount) {
suggestions += it
@putraxor
putraxor / RatioViewPager.java
Created March 27, 2017 19:05 — forked from AlexBlokh/RatioViewPager.java
ViewPager with custom aspect ratio
public class RatioViewPager extends ViewPager {
private float mRatio = 1f;
public RatioViewPager(Context context) {
super(context);
}
public RatioViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
@putraxor
putraxor / PersistentCookieStore.java
Created March 25, 2016 03:24 — forked from franmontiel/PersistentCookieStore.java
A persistent CookieStore implementation for use in Android with HTTPUrlConnection or OkHttp 2. -- For a OkHttp 3 persistent CookieJar implementation you can use this library: https://github.com/franmontiel/PersistentCookieJar
/*
* Copyright (c) 2015 Fran Montiel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@putraxor
putraxor / InstagramPostHelper.java
Created March 18, 2016 07:36
Instagram Upload Image With Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpCookie;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;