Skip to content

Instantly share code, notes, and snippets.

View devxoul's full-sized avatar
👨‍💻
Always coding

Suyeol Jeon devxoul

👨‍💻
Always coding
View GitHub Profile
@devxoul
devxoul / git-pruneoff
Last active February 4, 2022 10:51
Git Prune Off: Delete merged branches.
#!/bin/bash
# https://gist.githubusercontent.com/devxoul/72adcb880b273a36420d/raw/git-pruneoff
# Delete merged branches.
git branch --merged | awk '{if($1 != "*" && ($1 != "master" || $1 != "main")) print $1}' | xargs git branch -d
const getFileFromURL = async (url: string): Promise<File> => {
const result = await fetch(url)
const buffer = await result.arrayBuffer()
const blob = new Blob([buffer])
const file = new File([blob], url.split('/')[1])
return file
}
// Usage
const someFile: File
- node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js
+ ../MyApp/node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js
_getFileData(file) {
const relativePath = fastPath.relative(this._rootDir, file);
+ if (file.endsWith('node_modules/metro/src/node-haste/DependencyGraph/assets/empty-module.js')) {
+ console.log('rootDir:', this._rootDir);
+ console.log('file:', file);
+ console.log('relativePath:', relativePath);
+ }
return this._files.get(relativePath);
}
@devxoul
devxoul / ios10-url-open-location-service.swift
Created February 14, 2017 10:02
Open Settings > Privacy > Location Service in iOS 10
// Example Usage
func openLocation() {
guard let workspaceClass = NSClassFromString("LSApplicationWorkspace") else { return }
let workspace: AnyObject = execute(workspaceClass, "defaultWorkspace")
let url = URL(string: "Prefs:root=Privacy&path=LOCATION")!
execute(workspace, "openSensitiveURL:withOptions:", with: url)
}
private func getImplementation(_ owner: AnyObject, _ name: String) -> IMP {
let selector = Selector(name)
@devxoul
devxoul / git-reorder
Last active February 26, 2021 07:34
$ git reorder HEAD~3
# https://gist.github.com/devxoul/00b5b4fac4243075656dc79912e256d6
git rebase --exec 'git commit --amend -C HEAD --date="$(date -R)" && sleep 1.05' $1
@devxoul
devxoul / ApolloMockedProviderDynamicVariables.tsx
Last active February 23, 2021 09:11
Use expect matcher in Apollo MockedProvider variables
jest.mock('@wry/equality', () => ({
equal: (lhs: any, rhs: any) => {
const equals = require('expect/build/jasmineUtils').equals(lhs, rhs)
return equals || jest.requireActual('@wry/equality').equal(lhs, rhs)
}
}))
const mocks = [
{
@devxoul
devxoul / Spy.ts
Created February 12, 2021 12:24
Jest Spy type
type Spy<T extends {}, M extends jest.FunctionPropertyNames<Required<T>>> = Required<T>[M] extends (...args: any[]) => any
? jest.SpyInstance<ReturnType<Required<T>[M]>, jest.ArgsType<Required<T>[M]>>
: never;
@devxoul
devxoul / seoulpokemap-iv-filter.js
Last active February 3, 2021 03:14
IV filter for seoulpokemap.com
function filteredPokemonsByIV(pokemons, iv) {
iv = iv || 0.9;
return pokemons.filter(function (pokemon) {
var currentIV = (pokemon.attack + pokemon.defence + pokemon.stamina) / 45;
return currentIV >= iv;
});
}
function arePokemonsEqual(lhs, rhs) {
if (lhs.length != rhs.length) {
@devxoul
devxoul / git-pushme
Last active January 27, 2021 08:02
Git Push Me: Git push current branch to origin.
#!/bin/bash
# https://gist.githubusercontent.com/devxoul/a972ba0db2a25b989887/raw/f62353501becb274eb63c76b83fbcc01250a286d/git-pushme
# git push origin CURRENT_BRANCH
BRANCH=$(git branch --list | awk '{ if ($1 == "*") print $2 }')
while true; do
read -p "Push branch '$BRANCH' to origin? [Y/n] " -n 1 -r
echo