Skip to content

Instantly share code, notes, and snippets.

View paulocoutinhox's full-sized avatar

Paulo Coutinho paulocoutinhox

View GitHub Profile
find . -type f | sed -e 's/.*\.//' | sort | uniq -c | sort -n | grep -Ei '(java|kt|cpp)$'
@paulocoutinhox
paulocoutinhox / flutter-load-db.dart
Created July 14, 2020 05:50
Create a fresh or not database with Flutter
Future<Database> loadDatabase() async {
bool alwaysFreshDatabase = true;
if (alwaysFreshDatabase) {
var databasesPath = await getDatabasesPath();
var path = join(databasesPath, 'bible.db');
// delete existing if any
await deleteDatabase(path);
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
@paulocoutinhox
paulocoutinhox / MemorySamples.cpp
Last active December 21, 2018 00:53
C++ memory samples
#include <iostream>
#include <string>
#include <vector>
#include <memory>
void show_1(int value) {
std::cout << "show_1: " << &value << std::endl;
}
void show_2(int & value) {
@paulocoutinhox
paulocoutinhox / OkHttpUtils.java
Created November 19, 2018 13:57
OkHttp utility class to stop call by tag
package com.prsolucoes.android;
import android.text.TextUtils;
import okhttp3.Call;
import okhttp3.OkHttpClient;
public class OkHttpUtils {
public static void cancelCallWithTag(OkHttpClient client, String tag) {
@paulocoutinhox
paulocoutinhox / workaround-player.m
Created September 19, 2018 16:26
Workaround to enable audio session
- (void)activateAudioSession
{
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
}
@paulocoutinhox
paulocoutinhox / xcode-clean.sh
Created May 21, 2018 21:35
Clean Xcode files
#!/bin/sh
text_magenta=$(tput setaf 5)
text_bold=$(tput bold)
text_normal=$(tput sgr0)
archives_path=~/"Library/Developer/Xcode/Archives"
derived_data_path=~/"Library/Developer/Xcode/DerivedData"
simulator_data_path=~/"Library/Developer/CoreSimulator/Devices"
device_support_path=~/"Library/Developer/Xcode/iOS DeviceSupport"
@paulocoutinhox
paulocoutinhox / xcode-envs.txt
Created January 3, 2018 01:58
Xcode Environment Variables
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@paulocoutinhox
paulocoutinhox / install-cmake.sh
Created December 21, 2017 20:55
Install CMake 3.10 from source
version=3.10
build=1
mkdir ~/temp
cd ~/temp
wget https://cmake.org/files/v$version/cmake-$version.$build.tar.gz
tar -xzvf cmake-$version.$build.tar.gz
cd cmake-$version.$build/
./bootstrap
make -j4
sudo make install
@paulocoutinhox
paulocoutinhox / gist:a73129f7ee8d126cb9ac5fcc66a45555
Created December 15, 2017 21:47
check-your-system-clock.log
shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0//temp/log.do_configure:Check your system clock
shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0//temp/log.do_configure.12548:Check your system clock
shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0//automake-1.15.1/configure:Check your system clock" "$LINENO" 5
grep: shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0//automake-1.15.1/patches/0001-automake-Add-default-libtool_tag-to-cppasm.patch: No such file or directory
grep: shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0//automake-1.15.1/patches/new_rt_path_for_test-driver.patch: No such file or directory
grep: shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0//automake-1.15.1/patches/automake-replace-w-option-in-shebangs-with-modern-use-warnings.patch: No such file or directory
grep: shared/rpi3-custom/build/tmp/work/x86_64-linux/automake-native/1.15.1-r0//automake-1.