Skip to content

Instantly share code, notes, and snippets.

@sryze
sryze / webivew_crash_fix.kt
Last active Jul 25, 2020
Fix WebView crash when running on Android emulator: A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid XXX (RenderThread), pid YYY
View webivew_crash_fix.kt
val isHardwareAccelerated =
window.attributes.flags and WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED != 0
if (isHardwareAccelerated) {
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null)
} else {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
}
@sryze
sryze / Preferences.sublime-settings
Created Apr 18, 2020
Sublime Text 3 - Settings
View Preferences.sublime-settings
{
"color_scheme": "Packages/User/SublimeLinter/base16-ocean.dark (SL).tmTheme",
"enable_tab_scrolling": false,
"ensure_newline_at_eof_on_save": true,
"font_face": "Source Code Pro",
"font_size": 11,
"hot_exit": false,
"ignored_packages":
[
"GitStatus",
View mergeArraysKeepOrder.js
function mergeArraysKeepOrder(a1, a2) {
var a = [];
var i = 0, j = 0;
while (true) {
for (; i < a1.length; i++) {
if (a2.indexOf(a1[i], j) != -1) {
i++;
break;
}
a.push(a1[i]);
View history_up_down_keys.sh
# Put this in /etc/profile.d/history_up_down_keys.sh
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
@sryze
sryze / capitalize.js
Last active Jan 7, 2020
Capitalize every word in a string
View capitalize.js
export function capitalizeWords(text) {
let result = '';
let wordCharIndex = 0;
for (let i = 0; i < text.length; i++) {
let c = text.charAt(i);
if (/\s/.test(c)) {
wordCharIndex = 0;
} else {
if (wordCharIndex == 0) {
c = c.toUpperCase();
@sryze
sryze / cdump.c
Last active Jan 4, 2019
Generate C code from a file
View cdump.c
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE *file;
FILE *out_file;
unsigned char c;
@sryze
sryze / patch-xcode-projects.sh
Created Dec 16, 2018
Suppress "Update to recommended settings" warnings in Xcode projects of third-party React Native packages
View patch-xcode-projects.sh
#!/bin/sh
# Add this to your postinstall script in package.json:
# "scripts": {
# "postinstall": "path/to/patch-xcode-projects.sh"
# }
if [[ "$(uname -a)" = *"Darwin"* ]]; then
echo "Patching Xcode projects"
for project in $(find node_modules -name '*.pbxproj'); do
@sryze
sryze / clear-react-native-shit.sh
Last active Dec 5, 2018
Clear react-native caches on macOS (to fix some weird ass bug / make things work again)
View clear-react-native-shit.sh
#!/bin/sh
rm -rf $TMPDIR/metro-*
rm -rf $TMPDIR/haste-*
watchman watch-del-all
@sryze
sryze / handlebars-script-stylesheet-refs.js
Last active Jul 3, 2017
Handlebars helpers for adding references to scripts / stylesheets
View handlebars-script-stylesheet-refs.js
// Usage: {{scriptRef "your_script.js"}}
Handlebars.registerHelper('scriptRef', function(url) {
var scripts = document.head.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src && scripts[i].src.indexOf(url) !== -1) {
return;
}
}
var script = document.createElement('script');
@sryze
sryze / UITableViewBounceBackground.m
Last active Jun 9, 2017
Cover bounce area in UITableView / UIScrollView
View UITableViewBounceBackground.m
- (void)layoutBounceBackground {
// Change position and height of the bounce background view in order to cover the scroll view
// bounce area. This is necessary because of UITableView glitches in section and row animations
// during which you can see its (white) background in the middle of the table (with dark cells).
CGFloat contentHeight = self.tableView.contentSize.height;
CGFloat contentOffsetY = self.tableView.contentOffset.y;
CGFloat height = self.tableView.frame.size.height;
if (contentOffsetY >= 0 && contentOffsetY <= contentHeight - height) {
You can’t perform that action at this time.