Skip to content

Instantly share code, notes, and snippets.

@Nathaniel100
Nathaniel100 / svn_resolve.md
Created May 30, 2016 13:18
svn: how to resolve “local edit, incoming delete upon update” message

svn: how to resolve “local edit, incoming delete upon update” message

$ svn st
!  +  C foo
      >   local edit, incoming delete upon update
!  +  C bar
      >   local edit, incoming delete upon update
$ touch foo bar
$ svn revert foo bar
$ rm foo bar
@Nathaniel100
Nathaniel100 / svn_rm.md
Created May 30, 2016 13:20
svn rm files that not exists

svn st | grep ^! | awk '{print " --force "$2}' | xargs svn rm

@Nathaniel100
Nathaniel100 / styles.xml
Created June 1, 2016 16:58
material design theme
<resources>
<!-- inherit from the AppCompat theme -->
<style name="AppTheme" parent="Theme.AppTheme">
<!-- your app branding color for the app bar -->
<item name="colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/primary_dark</item>
task unzip(type: Copy) {
def zipFile = file('src/dists/dist.zip')
def outputDir = file("${buildDir}/unpacked/dist")
from zipTree(zipFile)
into outputDir
}
@Nathaniel100
Nathaniel100 / ScrollAwareFABBehavior.java
Created June 4, 2016 15:35
FloatingActionButton dismisses when scroll down, and shows when scroll up
/*
* Copyright 2015 The Android Open Source Project
*
* 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
@Nathaniel100
Nathaniel100 / opacity
Created June 6, 2016 08:01
hex opacity value
Hex Opacity Values
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
@Nathaniel100
Nathaniel100 / android.mk
Created June 15, 2016 08:37
Build libevent as seperate library, Android JNI
####################################
# Build libevent as separate library
include $(CLEAR_VARS)
LOCAL_MODULE:= libevent
LOCAL_MODULE_TAGS:= optional
LOCAL_SRC_FILES := \
third_party/libevent/event.c \
third_party/libevent/evutil.c \
third_party/libevent/epoll.c \
third_party/libevent/log.c \
@Nathaniel100
Nathaniel100 / clang_ndk.md
Created June 22, 2016 03:19
NDK uses clang

libc++_static isn't a proper value for APP_STL, it should be c++_static here.

NDK_TOOLCHAIN_VERSION has no effect when set inside Android.mk, it should be set inside Application.mk

LOCAL_CLANG is a variable used inside system modules from AOSP, not when using the NDK.

Since you're setting APP_STL as c++_static, the NDK toolchain will correctly tell the linker what lib to use, you shouldn't add LOCAL_LDLIBS := -lc++_static.

Also, you set APP_ABI to only armeabi-v7a, is it on purpose ? Android runs on other architectures as well and you'll get better performance on these if you also compile your libraries accordingly. You can either set APP_ABI to all or to a list of architectures armeabi-v7a x86...

@Nathaniel100
Nathaniel100 / C++ Advice1.md
Last active June 23, 2016 08:40
For starters, here are a few high-level recommendations derived from the sections on design, learning, and history of C++:
  1. Represent ideas (concepts) directly in code, for example, as a function, a class, or an enu- meration; §1.2.
  2. Aim for your code to be both elegant and efficient; §1.2.
  3. Don’t overabstract; §1.2.
  4. Focus design on the provision of elegant and efficient abstractions, possibly presented as libraries; §1.2.
  5. Represent relationships among ideas directly in code, for example, through parameteriza- tion or a class hierarchy; §1.2.1.
  6. Represent independent ideas separately in code, for example, avoid mutual dependencies among classes; §1.2.1.
  1. Don’t panic! All will become clear in time; §2.1.
  2. You don’t have to know every detail of C++ to write good programs; §1.3.1.
  3. Focus on programming techniques, not on language features; §2.1.