Skip to content

Instantly share code, notes, and snippets.

View morajabi's full-sized avatar

Mo morajabi

View GitHub Profile
@frankchang0125
frankchang0125 / tableView_setContentOffset.swift
Created July 28, 2016 17:10
Scroll to the offset after reloading tableView
/* We call layoutIfNeeded() immediately after reloadData()
* to force table view to perform layout immediately
* This is required to let the setContentOffset() in dispatch block to be executed
* after table view has completed performing its layout to scroll to the correct offset
* For further explanations, please see: http://goo.gl/BpzlA5 and http://goo.gl/6CH64b
*/
self.tableView.reloadData()
self.tableView.layoutIfNeeded()
dispatch_async(dispatch_get_main_queue(), {
@knowbody
knowbody / RNfontWeights.js
Created July 14, 2016 13:42
React Native Font Weight Cheatsheet iOS
{ fontWeight: '100' }, // Thin
{ fontWeight: '200' }, // Ultra Light
{ fontWeight: '300' }, // Light
{ fontWeight: '400' }, // Regular
{ fontWeight: '500' }, // Medium
{ fontWeight: '600' }, // Semibold
{ fontWeight: '700' }, // Bold
{ fontWeight: '800' }, // Heavy
{ fontWeight: '900' }, // Black
@samyk
samyk / chrome_tabs.osa
Created June 14, 2016 18:36
applescript to show all url+titles of Chrome tabs along with front window+tab url+title
# shows all url+titles of Chrome along with front window+tab url+title
set titleString to ""
tell application "Google Chrome"
set window_list to every window # get the windows
repeat with the_window in window_list # for every window
set tab_list to every tab in the_window # get the tabs
repeat with the_tab in tab_list # for every tab
@williampsena
williampsena / js-call-apply.es6.js
Created June 5, 2016 23:53
Javascript Call and Apply - ES6
function notifyClient(message) {
alert(message);
}
function sendMail(customer, total) {
notifyClient.call(this, `TODO: Send mail, (${String(customer.id)}, ${String(total)})`);
}
function getDeals() {
var product = arguments[0];
@westerlund
westerlund / NSImageDisk.swift
Created November 29, 2015 10:25
Write NSImage to disk
extension NSImage {
func writeToFile(file: String, atomically: Bool, usingType type: NSBitmapImageFileType) -> Bool {
let properties = [NSImageCompressionFactor: 1.0]
guard
let imageData = TIFFRepresentation,
imageRep = NSBitmapImageRep(data: imageData),
fileData = imageRep.representationUsingType(type, properties: properties) else {
return false
}
return fileData.writeToFile(file, atomically: atomically)
@paulirish
paulirish / what-forces-layout.md
Last active April 19, 2025 04:59
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@leommoore
leommoore / file_magic_numbers.md
Last active April 19, 2025 13:38
File Magic Numbers

File Magic Numbers

Magic numbers are the first bits of a file which uniquely identify the type of file. This makes programming easier because complicated file structures need not be searched in order to identify the file type.

For example, a jpeg file starts with ffd8 ffe0 0010 4a46 4946 0001 0101 0047 ......JFIF.....G ffd8 shows that it's a JPEG file, and ffe0 identify a JFIF type structure. There is an ascii encoding of "JFIF" which comes after a length code, but that is not necessary in order to identify the file. The first 4 bytes do that uniquely.

This gives an ongoing list of file-type magic numbers.

Image Files

@carlcalderon
carlcalderon / normalize-fonts.css
Created March 12, 2014 14:20
Normalized font-rendering in common browsers
/*
There are duplicate properties that seems to behave differently pending on browser version (see -moz-font-smoothing).
This is the most consistent I've found so far between vendors.
Please fork and improve!
*/
body {
-webkit-text-rendering: optimizeLegibility;
-moz-text-rendering: optimizeLegibility;
-ms-text-rendering: optimizeLegibility;
@blackfalcon
blackfalcon / git-feature-workflow.md
Last active April 3, 2025 00:42
Git basics - a general workflow

Git-workflow vs feature branching

When working with Git, there are two prevailing workflows are Git workflow and feature branches. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited, and the focus of this article.

If you are new to Git and Git-workflows, I suggest reading the atlassian.com Git Workflow article in addition to this as there is more detail there than presented here.

I admit, using Bash in the command line with the standard configuration leaves a bit to be desired when it comes to awareness of state. A tool that I suggest using follows these instructions on setting up GIT Bash autocompletion. This tool will assist you to better visualize the state of a branc

@adamwiggins
adamwiggins / adams-heroku-values.md
Last active November 27, 2024 17:06
My Heroku values

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style