Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
// Compile : $ clang add.c -lpthread -w -o add
// atau $ gcc add.c -lpthread -w -o add
// https://stackoverflow.com/questions/24947446/pthread-create-how-do-i-get-the-returned-value-from-the-passed-function
#define TOTAL_CPU 8
#define LOOP_MAX 800000000 // LOOP_MAX nilainya sebesar memory fisik yang tersedia, jika terlalu besar akan segfault
#define LOOP_THREAD LOOP_MAX/TOTAL_CPU
@u-r-w
u-r-w / m4a-to-mpr.md
Created April 24, 2020 08:07 — forked from pftg/m4a-to-mpr.md
Compress m4a with audio notes
ffmpeg -i tmp/audio-notes.m4a -acodec libmp3lame -aq 9 tmp/audio-notes.mp3
for file in *.m4a ; do ffmpeg -i $file -acodec libmp3lame -aq 9 ${file%.m4a}.mp3 ; done
# Extract many files with one command
function extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) tar Jxvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;

React Native Folder Structure

Motivations

  • Sharing what has worked for me in different React Native projects
  • Reusing screens in different parts of your app
  • Easy to work separately in a feature
  • Add an extra level (nested folder) only when necessary
  • Don't overuse index.js for everything
#!/home/umar/.nvm/versions/node/v8.11.3/bin/node
let fs = require("fs");
let text = fs.readFileSync("text.txt", "utf-8");
text.split("\n").forEach(function(line) {
let reverse = line.split("").reverse().join("")
if (line.toLowerCase() === reverse) {
console.log("Detected palindrome at:", line);
}
module.exports = {
googleClientID: "YOUR_GOOGLE_CLIENT_ID",
googleClientSecret: "YOUR_CLIENT_SECRET"
}
@u-r-w
u-r-w / index.js
Last active October 9, 2018 15:28
const express = require('express');
const passport = require('passport');
const GoogleStrategy = require('passport-google-oauth20').Strategy;
const keys = require('./config/key')
const app = express();
passport.use(new GoogleStrategy(
{
import React from 'react';
import { View, TextInput, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { connect } from "react-redux";
import { passwordChecker } from '../Action/TextInputCheckerAction';
class TextInputChecker extends React.Component {
checker(){
const passwordParam = "^(?=.{5,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$"
import { combineReducers } from "redux";
import textInputCheckerReducer from '../Reducer/TextInputCheckerReducer';
export default combineReducers({
textInputCheckerReducer
})
import { PASSWORD_CHANGED } from '../Action/types';
const initialState = { password: '' }
export default function textInputCheckerReducer (state= initialState, action){
console.log(action);
switch(action.type) {
case PASSWORD_CHANGED:
return { ...state, password: action.payload }
default:
return state