Skip to content

Instantly share code, notes, and snippets.

View mingca's full-sized avatar
🇨🇦

mingca

🇨🇦
View GitHub Profile
/*
Flatten Array - exactly same with Ruby's Array#flatten
Example:
flatten([[1, 2, 3], [4, 5]]); // [1, 2, 3, 4, 5]
*/
function flatten(arr) {
return arr.reduce(function (flat, toFlatten) {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
@blankg
blankg / WebViewBridge.js
Last active July 12, 2022 06:53
For RN >= 0.57 please look at https://github.com/blankg/rn-webview-bridge-sample-new/blob/master/resources/index.html. Provides a sample implementation for sending and receiving messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
/**
* Created by Guy Blank on 3/9/17.
*
* This is a sample provides an API to send & receive messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
* A sample project that uses the bridge is available here https://github.com/blankg/rn-webview-bridge-sample
*
* webViewBridge.send('functionToInvoke', {mydata: 'test'}, function(){console.log('success')},function(){console.log('error')});
*
* The API is designed to be similar to the Cordova exec API so migration to it should be almost seamless.
* The API also provides solution to a React-Native WebView bug in iOS which causes sending consecutive postMessage calls to override each other.
@p3t3r67x0
p3t3r67x0 / prefixed-office-properties.md
Last active February 20, 2024 19:15
MS Office prefixed style properties can be used for older versions of MS Excel, MS PowerPoint or MS Word when you want to save a document, presentation, workbook, or worksheet as a web document, or even in older versions for MS Outlook.

MS Office prefixed style properties

mso-ansi-font-size

Note: Office only

mso-ansi-font-size: large | larger | <length> | medium | <percentage> | small | smaller | x-large | x-small | xx-large | xx-small
@Fivell
Fivell / have_xml.rb
Created December 18, 2013 17:00 — forked from faun/have_xml.rb
require 'nokogiri'
RSpec::Matchers.define :have_xml do |xpath, text|
match do |body|
doc = Nokogiri::XML::Document.parse(body)
nodes = doc.xpath(xpath)
nodes.empty?.should be_false
if text
nodes.each do |node|
node.content.should == text
end
@yannvery
yannvery / 0_Paginate_without_reload_all_page_with_kaminari.md
Last active November 3, 2022 11:11
How to paginate on an ajax way ( with jquery and kaminari )

Paginate with Kaminari without reload all data

Use :remote => true option on link_to and paginate Region index page

@caok
caok / gist:4065758
Created November 13, 2012 13:27
Deploy from a git tag with capistrano
ref: http://nathanhoad.net/deploy-from-a-git-tag-with-capistrano
Deploy from a Git tag with Capistrano
Are you using Capistrano and Git and want to easily deploy from Git tags? It couldn't be simpler
Using Git, tag a new release:
git tag -a 09.10.02.01 -m "Tagging a release"
You can use git tag to list your tags: