Skip to content

Instantly share code, notes, and snippets.

View chanphiromsok's full-sized avatar
🎯
Focusing

Chanphirom Sok chanphiromsok

🎯
Focusing
  • Cambodia
View GitHub Profile
@chanphiromsok
chanphiromsok / instructions.md
Created January 30, 2024 03:47 — forked from wosephjeber/instructions.md
Ecto migration for renaming table with indexes and constraints

Renaming table in Ecto migration

I recently wanted to rename a model and its postgres table in a Phoenix app. Renaming the table was simple and documented, but the table also had constraints, sequences, and indexes that needed to be updated in order for the Ecto model to be able to rely on default naming conventions. I couldn't find any examples of what this would look like but was eventually able to figure it out. For anyone else in the same situation, hopefully this example helps.

In the example below, I'm renaming the Permission model to Membership. This model belongs to a User and an Account, so it has foreign key constraints that need to be renamed.

defmodule MyApp.Repo.Migrations.RenamePermissionsToMemberships do
  use Ecto.Migration
@chanphiromsok
chanphiromsok / Readme.md
Created December 20, 2023 14:08 — forked from PierreThiollent/Readme.md
iTerm2 and Oh-my-zsh config

Setup iTerm2 and oh-my-zsh

Enjoy ! 😄

Install iTerm 2

Download iTerm2 here.

@chanphiromsok
chanphiromsok / AStepIndicator.swift
Created December 11, 2023 03:50 — forked from Dev1an/AStepIndicator.swift
Simple step indicator view for iOS using UIStackView, IBDesignable, IBInspectable, Auto Layout
//
// Stepper.swift
// Stepperindicator
//
// Created by Damiaan on 13/01/2019.
// Copyright © 2019 Devian. All rights reserved.
//
import UIKit
@chanphiromsok
chanphiromsok / README.md
Created August 11, 2023 04:02 — forked from cskeppstedt/README.md
Modify proguard rules in a managed expo project

Modify proguard rules in a managed expo project

If you ever need to modify the proguard rules for the Android-part of your Expo managed workflow, you can achieve this by using a config plugin.

  1. Make a folder for config-plugins called ./plugins in the project root folder.
  2. Place the withProguardRules.js and my-proguard-rules.pro in the folder
  3. Add the config plugin to the plugins array of your app.config.js (or app.json if you're using that instead).

NOTE: if you rename your .pro file, don't forget to change the two occurrences of my-proguard-rules in withProguardRules.js as well.

@chanphiromsok
chanphiromsok / picker
Created August 3, 2023 04:09 — forked from dungkaka/picker
Convert wheel picker to reanimated 2
import React from "react";
import { Dimensions, StyleSheet, Text, View } from "react-native";
import { PanGestureHandler } from "react-native-gesture-handler";
import Animated, {
Easing,
Extrapolate,
interpolate,
useAnimatedGestureHandler,
useAnimatedReaction,
useAnimatedStyle,
defmodule Snowflake do
use Application
def start(_type, _args) do
import Supervisor.Spec
children = [
worker(:riak_core_vnode_master, [Snowflake.VNode]),
]
import android.provider.Settings;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import android.util.Log;
import android.net.Uri;
@chanphiromsok
chanphiromsok / PermissionUtil.java
Created June 16, 2023 00:17 — forked from thoinv/PermissionUtil.java
Permission Util #android #utils #permission
@SuppressLint("WrongConstant")
public static boolean canDrawOverlays(Context context) {
if (Build.VERSION.SDK_INT >= 23) {
return Settings.canDrawOverlays(context);
} else {
if (Build.MANUFACTURER.equalsIgnoreCase("xiaomi")) {
return true;
}
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService("appops");
Method method = null;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import java.lang.reflect.Method;
// MIUI. Redefining Android.