Skip to content

Instantly share code, notes, and snippets.

View WrathChaos's full-sized avatar
❤️‍🔥
Working Hard

FreakyCoder WrathChaos

❤️‍🔥
Working Hard
View GitHub Profile
@WrathChaos
WrathChaos / prevent-go-back-react-navigation-v6.md
Last active May 30, 2023 04:21
How to prevent go back with React Navigation v6?
<Stack.Screen
  options={{ gestureEnabled: false }}
  name={SCREENS.ROOT}
  children={RootNavigator}
/>
@WrathChaos
WrathChaos / 1: App.js
Created January 5, 2022 09:57 — forked from helenaford/1: App.js
useNotificationService
import { useNotificationService } from './hooks';
function App() {
useNotificationService();
...
}
var mediaJSON = { "categories" : [ { "name" : "Movies",
        "videos" : [ 
		    { "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
              "sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
              "subtitle" : "By Blender Foundation",
              "thumb" : "images/BigBuckBunny.jpg",
              "title" : "Big Buck Bunny"
            },
            { "description" : "The first Blender Open Movie from 2006",
func greetingLogic() -> String {
  let hour = Calendar.current.component(.hour, from: Date())
  
  let NEW_DAY = 0
  let NOON = 12
  let SUNSET = 18
  let MIDNIGHT = 24
  
 var greetingText = "Hello" // Default greeting text
func greetingLogic() -> String {
  let date = NSDate()
  let calendar = NSCalendar.current
  let currentHour = calendar.component(.hour, from: date as Date)
  let hourInt = Int(currentHour.description)!
  
  let NEW_DAY = 0
  let NOON = 12
 let SUNSET = 18
fun convertBitmapToFile(context: Context, bitmap: Bitmap): Uri{  
  val file = File(Environment.getExternalStorageDirectory().toString() + File.separator + fileNameToSave)
  file.createNewFile()
  // Convert bitmap to byte array
  val baos = ByteArrayOutputStream()
  bitmap.compress(Bitmap.CompressFormat.PNG, 0, baos) // It can be also saved it as JPEG
  val bitmapdata = baos.toByteArray()
 }
@WrathChaos
WrathChaos / useEffectPrevState.md
Created April 21, 2020 13:52
Use Effect with Previous State
function usePrevious(value) {
  const ref = useRef();

  useEffect(() => {
  ref.current = value;
  });

  return ref.current;
}
@WrathChaos
WrathChaos / react-native-google-map-navigation.md
Created April 14, 2020 18:03
React Native Google Maps Navigation?
const createNavigationURL = (startLat, startLng, lat, lng) => {
  const scheme = Platform.select({
    ios: `maps:${startLat}?q=`,
    android: `geo:${startLng}?q=`
  });
  const latLng = `${lat},${lng}`;
  const label = "Custom Label";
  const url = Platform.select({
 ios: `${scheme}${label}@${latLng}`,
@WrathChaos
WrathChaos / TransparentStatusBar.md
Created March 8, 2020 16:43
How to Translucent StatusBar? Article:
import { Platform, StatusBar } from 'react-native';

StatusBar.setBarStyle("light-content");
if (Platform.OS === "android") {
  StatusBar.setBackgroundColor("rgba(0,0,0,0)");
  StatusBar.setTranslucent(true);
}