Skip to content

Instantly share code, notes, and snippets.

View paulocoutinhox's full-sized avatar

Paulo Coutinho paulocoutinhox

View GitHub Profile
@paulocoutinhox
paulocoutinhox / compiling_building_c_cpp_notes.md
Created August 2, 2021 23:37 — forked from gubatron/compiling_building_c_cpp_notes.md
Things to remember when compiling and linking C/C++ programs

Things to remember when compiling/linking C/C++ software

by Angel Leon. March 17, 2015; August 29, 2019.

Include Paths

On the compilation phase, you will usually need to specify the different include paths so that the interfaces (.h, .hpp) which define structs, classes, constans, and functions can be found.

With gcc and llvm include paths are passed with -I/path/to/includes, you can pass as many -I as you need.

In Windows, cl.exe takes include paths with the following syntax: /I"c:\path\to\includes\ you can also pass as many as you need.

/**
* Returns true when [Context] is unavailable or is about to become unavailable
*/
fun Context?.isDoomed(): Boolean = when (this) {
null -> true
is Application -> false
is Activity -> (this.isDestroyed or this.isFinishing)
else -> false
}
fun test1(callback: (() -> Unit)? = null) {
callback?.let {
it()
}
}
fun test2(callback: () -> Unit?) {
callback()
}
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"