Skip to content

Instantly share code, notes, and snippets.

View basebandit's full-sized avatar
🏠
Working from home

basebandit

🏠
Working from home
View GitHub Profile
{% macro render(form) -%}
<fieldset>
{% for field in form %}
{% if field.type in ['CSRFTokenField', 'HiddenField'] %}
{{ field() }}
{% else %}
<div class="clearfix {% if field.errors %}error{% endif %}">
{{ field.label }}
<div class="input">
@basebandit
basebandit / howto-standalone-toolchain.md
Created November 29, 2016 07:15 — forked from Tydus/howto-standalone-toolchain.md
How to install Standalone toolchain for Android

HOWTO Cross compiling on Android

5W1H

What is NDK

NDK (Native Develop Toolkit) is a toolchain from Android official, originally for users who writes native C/C++ code as JNI library. It's not designed for compiling standalone programs (./a.out) and not compatible with automake/cmake etc.

What is Standalone Toolchain

"Standalone" refers to two meanings:

  1. The program is standalone (has nothing connect to NDK, and don't need helper scripts to run it)
  2. The toolchain is made for building standalone programs and libs, and which can used by automake etc.

(Optional) Why NDK is hard to use

By default, NDK uses android flavor directory structure when it's finding headers and libs, which is different from GNU flavor, so the compiler cannot find them. For Example:

@basebandit
basebandit / Sidebar.vue
Created June 23, 2018 12:32
Dynamic routing with router params
<template>
...
<template v-if="countMemories !== 0">
<v-list two-line>
<template v-for="(memory, index) in memories">
<v-list-tile :to="{path: '/event/' + memory.title}" :key="memory.title" avatar>
<v-list-tile-avatar v-if="!memory.done">
<img src="../assets/memory.png">
</v-list-tile-avatar>
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
</div>
</template>
<script>
export default {
name: 'Memory',
import Vue from 'vue'
import Router from 'vue-router'
import Stats from '@/components/Stats'
import Memory from '@/components/Memory'
Vue.use(Router)
export default new Router({
routes: [
{
@basebandit
basebandit / after_res_hooks.js
Created July 5, 2018 07:40 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@basebandit
basebandit / utils.js
Created August 9, 2018 08:34 — forked from dc198689/utils.js
build/utils.js
exports.cssLoaders = function(options) {
...
...
function resolveResouce(fileName) {
// Absolute Path
return path.resolve(__dirname, '../src/assets/scss/' + fileName)
}
function generateSassResourceLoader() {
var loaders = [
@basebandit
basebandit / bcrypt-promise.js
Created October 11, 2018 08:03 — forked from dmh2000/bcrypt-promise.js
Using bcrypt with promises to hash a password and then verify it
let bcrypt = require('bcrypt-nodejs');
let password = "hello";
let stored_hash = "";
// first generate a random salt
function genSalt(password) {
return new Promise((resolve,reject) => {
bcrypt.genSalt(10,function(err,salt) {
if (err) {
@basebandit
basebandit / primes.go
Last active July 15, 2019 16:05
Get all integer prime numbers from 0 to 100
package main
import (
"fmt"
"math"
)
func main() {
for i := 0; i < 100; i++ {
if isPrime(i) {
@basebandit
basebandit / copy.go
Created July 30, 2019 07:58
Copy copies file contents from source to destination. If the file already exists it's content will be replaced by the contents of the source file
// copyFile copies a file from src to dst. If src and dst files exist, and are
// the same, then return success. Otherise, copy the file contents from src to dst.
func copyFile(src, dst string) (err error) {
sfi, err := os.Stat(src)
if err != nil {
return
}
if !sfi.Mode().IsRegular() {
// cannot copy non-regular files (e.g., directories,
// symlinks, devices, etc.)