Skip to content

Instantly share code, notes, and snippets.

@mshivam019
mshivam019 / ScreenWebview.jsx
Created February 14, 2024 19:21
A feature rich webview for react native
import {useState, useEffect, useRef, useCallback} from 'react';
import {View,Text,BackHandler, Share as RNshare, Platform} from 'react-native';
import {WebView} from 'react-native-webview';
import {useRoute, useNavigation} from '@react-navigation/native';
import {useFocusEffect, useIsFocused} from '@react-navigation/native';
import Share from 'react-native-share';
import ReactNativeBlobUtil from 'react-native-blob-util';
import styled from 'styled-components/native';
import axios from 'axios';
import HeaderComponentWithBackButton from '../components/HeaderComponentWithBackButton';
@devd123
devd123 / recursive function
Created April 14, 2017 10:43
Parent Child Tree PHP Recursion
public function getresultTree(array $elements, $parentId = 0) {
$branch = array();
foreach ($elements as $element) {
if ($element['parent_id'] == $parentId) {
$children = getresultTree($elements, $element['id']);
if ($children) {
@dogancelik
dogancelik / ansi-utf8-conversion.md
Last active May 14, 2024 04:09
ANSI / UTF-8 (with or without BOM) conversion #Windows

Using Uni2Me

  • It's free but discontinued.

Using UTFCast

  • Proprietary software
  • Allows conversion from ANSI to UTF-8 with or without BOM

Using Notepad++

@wojteklu
wojteklu / clean_code.md
Last active May 14, 2024 04:07
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@c22dev
c22dev / DEPSteps.md
Last active May 14, 2024 04:03
Remove MDM & DEP from an Apple Sillicon Mac (Sonoma)

How to make an MDM Mac shine like it's brand new ?

Works, as of 14/04/2024, on macOS 14.4.1 and lower (prob higher but idk)

This was made for Apple Sillicon Macs.

Restore Process

You need another Mac for this.

If you don't have one and have recovery locked, it's not possible.

@hehefan
hehefan / heat-map.py
Created November 23, 2017 09:37
OpenCV heat map
import cv2
img = cv2.imread('img.jpg')
h, w, _ = img.shape
# attention: one-dimentional vector
attention /= max(attention)
attention = attention.reshape((7,7))
atten_norm = cv2.resize(attention, dsize=(w,h))
atten_norm = atten_norm* 255
heat_map = cv2.applyColorMap(atten_norm.astype(np.uint8), cv2.COLORMAP_JET)
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
@slightfoot
slightfoot / page_turn.dart
Created September 9, 2019 21:28
Page Turn Effect - By Simon Lightfoot. Replicating this behaviour. https://www.youtube.com/watch?v=JqvtZwIJMLo
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@mba811
mba811 / default.custom.yaml
Last active May 14, 2024 03:59 — forked from lotem/default.custom.yaml
神級輸入法——Rime
# 中西文切換鍵的默認設置寫在 default.yaml 裏面
# 以下的 default.custom.yaml 在全局範圍重定義該組快速鍵
#
# 可用的按鍵有 Caps_Lock, Shift_L, Shift_R, Control_L, control_R
# Mac 系統上的鼠鬚管不能區分左、右,因此只有對 Shift_L, Control_L 的設定起作用
#
# 已輸入編碼時按切換鍵,可以進一步設定輸入法中西文切換的形式。
# 可選的臨時切換策略有三:
# inline_ascii 在輸入法的臨時西文編輯區內輸入字母、數字、符號、空格等,回車上屏後自動復位到中文
# commit_text 已輸入的候選文字上屏並切換至西文輸入模式
@berteh
berteh / ultimate-guitar-download.user.js
Last active May 14, 2024 03:59
download tabs/chords from ultimate-guitar.com song as a text file, simply hit CTRL+ALT+D after page is loaded.
// ==UserScript==
// @name download Ultimate Guitar tabs-chords
// @description hit CTRL+ALT+D after whole page is loaded to download tabs/chords of current page as a text file.
// @version 1.1
// @icon https://tabs.ultimate-guitar.com/static/public/img/product_icons/ug/favicon.ico
// @require http://code.jquery.com/jquery-latest.js
// @run-at document-end
// @downloadURL https://gist.github.com/berteh/8c052685905f58b64ccc44f272273506/raw/ultimate-guitar-download.user.js
// @match https://tabs.ultimate-guitar.com/*
// ==/UserScript==