Skip to content

Instantly share code, notes, and snippets.

View adityawibisana's full-sized avatar

Aditya Wibisana adityawibisana

View GitHub Profile
private void Animate(bool isDown, bool useDelay=true)
{
Storyboard storyboard = new Storyboard();
storyboard.SpeedRatio = useDelay ? 4 : 100000;
// translate the children
int i = 0;
foreach (Image image in rotationContainer.Children)
{
public void SetImages(String[] Images)
{
if (visibleItems > itemsAmount)
return;
// cleaning up
if (rotationContainer!=null)
rotationContainer.Children.Clear();
positions.Clear();
@adityawibisana
adityawibisana / launch.json
Last active April 22, 2019 14:31
Launch.json file that works on VSCode 1.30.1, node 8, run via play button.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch in WSL",
"useWSL": true,
"program": "${workspaceFolder}/app.js"
}
@adityawibisana
adityawibisana / launch.json
Last active April 21, 2019 13:44
VSCode launch.json for Node v4
{
"version": "0.2.0",
"configurations": [
{
"name": "WSL fix remoteRoot",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5858,
"sourceMaps": false,
@adityawibisana
adityawibisana / simpleExtensionFunctionUsage
Created July 9, 2019 12:30
simple custom function to run on UI and background respectively
//run this on default background thread
runOnDefaultThread({
firstNote = NoteRepository.getOrCreateFirstNote(applicationContext)
firstNoteLive = NoteRepository.getLiveDataNoteById(applicationContext, firstNote.id)
//run on main thread
runOnUiThread {
firstNoteLive.observe(this, Observer<Note> {
Log.v(TAG, "First note is changed, value: ${it.content}")
})
@adityawibisana
adityawibisana / CommonUtils.kt
Created July 9, 2019 12:35
Run on UI and background easily
import android.content.Context
import android.os.Handler
import android.os.HandlerThread
import android.os.Looper
import android.util.Log
object CommonUtils {
private const val TAG = "CommonUtils"
private val handler: Handler by lazy {
@adityawibisana
adityawibisana / UserController.js
Last active January 21, 2022 08:01
Medium Sails - Normal UserController for login and register
module.exports = {
register: (req, res) => {
if (!req.param("username")) {
return res.status(400).send({
code: 1,
message: `'username' parameter is needed`
})
}
... continue processing registration
},
@adityawibisana
adityawibisana / UserService.js
Last active January 21, 2022 08:33
Medium Sails User Service
module.exports = {
handleError: (req) => {
if (!req.param("username")) {
return {
code: 1,
message: `'username' parameter is needed`
}
}
return null
}
@adityawibisana
adityawibisana / UserController.js
Created January 21, 2022 08:22
Medium Sails UserController after error handling to UserService:
module.exports = {
register: (req, res) => {
const error = UserService.handleError(req)
if (error) {
return res.status(400).send(error)
}
... continue processing registration
},
login: (req, res) => {
@adityawibisana
adityawibisana / UserController.js
Created January 21, 2022 08:47
Medium Sails UserController final code https://medium.com/p/368d1713a82f
module.exports = {
register: (req, res) => {
... continue processing registration
},
login: (req, res) => {
... continue processing login
}
...
}