Skip to content

Instantly share code, notes, and snippets.

View saggafarsyad's full-sized avatar

Saggaf Arsyad saggafarsyad

View GitHub Profile
@saggafarsyad
saggafarsyad / SoftDelete.js
Last active November 7, 2018 00:11
Loopback SoftDelete Mixins
/**
* Loopback SoftDelete Mixins
*
* I write my own mixins because current available softdelete mixin is not working in Node.js v4.x.x, I believe it is caused by ES6
* This code is forked from https://github.com/gausie/loopback-softdelete-mixin
*
* To implement, Copy this file to mixins folder, and add "SoftDelete": true in mixins on YourModel.json file
*
* To delete a row or data, don't use destroyAll etc., use YourModel.delete
* To find data that is considered deleted, add includeDeleted: true in where filter
@saggafarsyad
saggafarsyad / JacksonRequest.java
Last active January 3, 2016 09:41
Volley Request with JSON Parsing using Jackson
/**
* Volley Request for passing JSON string with Jackson
*
* @TODO
* - Extend this class
*
* [email protected]
*/
public class JacksonRequest<T> extends Request<T> {
private final Class<T> mClass;
@saggafarsyad
saggafarsyad / LinearLayoutWithWeight.xml
Last active August 29, 2015 14:22
Android - Optimize LinearLayout and layout_weight using RelativeLayout
<!--I mostly use LinearLayout and layout_weight to give views the same width or height in a layout-->
<!--For example-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_weight="1"
@saggafarsyad
saggafarsyad / android-serviceToast.java
Last active August 5, 2019 14:51
Android - Show Toast from Service
// If you Service with threads, e.g. a Chat Service
// You want to show a toast such as indicating the connection is lost or stuff when your service is running foreground
// Get main the main thread, you are only allowed to draw UI in the main thread
Handler mainHandler = new Handler(getMainLooper());
mainHandler.post(new Runnable() {
@Override
public void run() {
// Do your stuff here related to UI, e.g. show toast