Skip to content

Instantly share code, notes, and snippets.

View keithics's full-sized avatar

Keith Levi Lumanog keithics

View GitHub Profile
export const BIRTH_SUCCESS = 'BIRTH_SUCCESS';
export const birthSuccess = (births) => ({
type: BIRTH_SUCCESS,
payload: { births },
});
export const loadBirths = (page) => async (dispatch) => {
const response = await request('/certificates/birth/page/', dispatch, page);
if (response) {
@keithics
keithics / sample.js
Created May 17, 2020 17:04
Sample Responses
// responses
export const SuccessResponse = function(res,data) {
if(data){
res.json(data)
}else{
ErrorResponse(res,{message:'Data is null',code:422})
}
}
@keithics
keithics / startDropMarkerAnimation.kt
Last active April 17, 2024 01:56
Animated Drop Marker Kotlin
private fun startDropMarkerAnimation(marker: Marker) {
val target = marker.position
val handler = Handler()
val start = SystemClock.uptimeMillis()
val proj = mMap!!.projection
val targetPoint = proj.toScreenLocation(target)
val duration = (200 + targetPoint.y * 0.6) as Double
val startPoint = proj.toScreenLocation(marker.position)
startPoint.y = 0
val startLatLng = proj.fromScreenLocation(startPoint)
@keithics
keithics / uploader.js
Last active March 14, 2018 05:58
Uploading images - MEAN STACK
//routes
app.route('/api/teams/logo').all()
.post(teams.upload).all(teamsPolicy.isAllowed)
//server.controller
//sharp = require('sharp') :: http://sharp.dimens.io/
exports.upload = function (req, res) {
var upload = multer(uploadConfig).single('photo');
upload(req, res, function (uploadError) {
if (uploadError) {
@keithics
keithics / password.client.service.js
Last active January 4, 2020 10:14
Generate Strong Password - Angular (minimum of 4 chars - random string with 1 uppercase, 1 number and 1 special character)
'use strict';
angular.module('users').factory('PasswordGenerator', function () {
return {
generate: function (length, useUpper, useNumbers, userSymbols) {
var passwordLength = length || 12;
var addUpper = useUpper || true;
var addNumbers = useNumbers || true;
var addSymbols = userSymbols || true;
@keithics
keithics / restcall.swift
Created February 24, 2016 03:12
Sample code for Swift with username and token
let params = ["username":username,"token":token,"param1":param1,"param2":param2]
RestClient.request(self,method:.POST,URLString: RestApi.MY_URL,parameters:params,
onSuccess:{ data in
self.saveCache(data)
},onError:{ error in
},onFailure:{
print("failed")
@keithics
keithics / middlewareAndRoutes.js
Created February 24, 2016 03:04
Token Middleware and Routes Sample
//route
app.route('/mobile/v2/updateuser')
.post(users.checkAuthMiddleWare,mobile.updateuser);
//middleware
exports.checkAuthMiddleWare = function(req, res,next) {
console.log(req.body);
User.findOne({username:req.body.username,token:req.body.token},function(err,user){
if(user){
next();
@keithics
keithics / users.authentication.server.controller.js
Last active February 24, 2016 03:04
token authentication
/**
* Signup
*/
exports.signup = function(req, res) {
console.log(req.body);
// For security measurement we remove the roles from the req.body object
delete req.body.roles;
// Init Variables
var user = new User(req.body);
@keithics
keithics / RestClient.swift
Created November 26, 2015 13:23
Alamofire Wrapper for iOS
//
// RestClient.swift
// USJ-R Mobile
//
// Created by keithics on 10/7/15.
// Copyright © 2015 Web Ninja Technologies. All rights reserved.
//
import Foundation
import Alamofire
@keithics
keithics / RestClient.java
Created November 26, 2015 13:21
Retrofit Class Wrapper for Android
package com.webninja.usjr.rest;
import com.squareup.okhttp.OkHttpClient;
import com.webninja.usjr.libs.AppConstants;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;
import retrofit.client.OkClient;