Skip to content

Instantly share code, notes, and snippets.

@indragiek
indragiek / ColorOverlay.m
Created May 3, 2011 03:30
Replicating Photoshop Layer Styles Using Core Graphics
CGContextRef ctx = UIGraphicsGetCurrentContext(); // your drawing context
CGRect colorRect = CGRectMake(0, 0, 100, 100); // the rect to draw the color overlay into
// Set the blend mode to "Normal"
// This is the default blend mode setting so this line is not required, shown here for demonstration
CGContextSetBlendMode(ctx, kCGBlendModeNormal);
// Set the opacity of the drawing context (once again, not required)
CGContextSetAlpha(ctx, 1.0);
// Create the red color
CGColorRef redColor = CGColorCreateGenericRGB(0.908, 0.149, 0.145, 1.000);
// Set the fill color of the context and fill the rect
@wader
wader / gist:1555889
Created January 3, 2012 17:19
Wav merge
// a bit hackish way of merging two wav files, assumes raw samples.
#import <Foundation/Foundation.h>
#define RIFF_ID 0x52494646 // "RIFF"
#define RIFF_FMT_ID 0x666d7420 // "fmt "
#define RIFF_DATA_ID 0x64617461 // "data"
typedef struct riffChunkHeader {
UInt32 rsc_id; // big endian
@tadast
tadast / countries_codes_and_coordinates.csv
Last active July 20, 2024 17:54
Countries with their (ISO 3166-1) Alpha-2 code, Alpha-3 code, UN M49, average latitude and longitude coordinates
Country Alpha-2 code Alpha-3 code Numeric code Latitude (average) Longitude (average)
Afghanistan AF AFG 4 33 65
Åland Islands AX ALA 248 60.116667 19.9
Albania AL ALB 8 41 20
Algeria DZ DZA 12 28 3
American Samoa AS ASM 16 -14.3333 -170
Andorra AD AND 20 42.5 1.6
Angola AO AGO 24 -12.5 18.5
Anguilla AI AIA 660 18.25 -63.1667
Antarctica AQ ATA 10 -90 0
@steipete
steipete / UITableViewMore.m
Last active January 29, 2018 14:19
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
@alyssaq
alyssaq / config.fish
Created April 30, 2015 03:54
config.fish set environment variables from bash_profile
# Fish shell
egrep "^export " ~/.bash_profile | while read e
set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\1/")
set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\2/")
# remove surrounding quotes if existing
set value (echo $value | sed -E "s/^\"(.*)\"\$/\1/")
if test $var = "PATH"
@jherax
jherax / arrayFilterFactory.1.ts
Last active July 18, 2024 15:02
Filters an array of objects with multiple match-criteria.
type FilterOperator = 'AND' | 'OR';
type FiltersBy<T> = {
[K in keyof T]?: (value: T[K]) => boolean;
};
/**
* Factory function that creates a specialized function to filter
* arrays, by validating all filters (AND operator),
* or validating just one of the filters (OR operator).
* @param operator Method to validate all filters: AND, OR
@chourobin
chourobin / 0-bridging-react-native-cheatsheet.md
Last active June 28, 2024 20:49
React Native Bridging Cheatsheet
@matthewjberger
matthewjberger / notes.md
Last active March 11, 2024 10:21
How to make an electron app using Create-React-App and Electron with Electron-Builder.
@andigu
andigu / TabParallax.js
Last active October 23, 2023 07:34
A react native component featuring parallax scrolling with tabs
import React, {Component} from "react";
import {Animated, Dimensions, Platform, Text, TouchableOpacity, View} from "react-native";
import {Body, Header, List, ListItem as Item, ScrollableTab, Tab, TabHeading, Tabs, Title} from "native-base";
import LinearGradient from "react-native-linear-gradient";
const {width: SCREEN_WIDTH} = Dimensions.get("window");
const IMAGE_HEIGHT = 250;
const HEADER_HEIGHT = Platform.OS === "ios" ? 64 : 50;
const SCROLL_HEIGHT = IMAGE_HEIGHT - HEADER_HEIGHT;
const THEME_COLOR = "rgba(85,186,255, 1)";
import React, { useRef, useState } from 'react'
import { View, Text, StyleSheet } from 'react-native'
import BottomSheet from 'reanimated-bottom-sheet'
import { FlatList } from 'react-native-gesture-handler'
import { Fragment } from 'react'
const data = Array(50)
.fill(0)
.map((item, index) => ({
id: `item-${index}`,