Skip to content

Instantly share code, notes, and snippets.

View franklixuefei's full-sized avatar
🎯
Focusing

Frank Li franklixuefei

🎯
Focusing
  • Microsoft
  • Seattle, Washington
View GitHub Profile
@hsablonniere
hsablonniere / README.md
Created May 2, 2012 22:42
scrollIntoViewIfNeeded 4 everyone!!!

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.

@mluton
mluton / gist:3990658
Created October 31, 2012 23:37
Display UIActivityViewController in a Popover
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"something"] applicationActivities:nil];
self.popover = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
self.popover.delegate = self;
[self.popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
@aspitz
aspitz / BidirectionalDictionary
Created November 2, 2014 14:54
Swift implementation of a bidirectional dictionary
struct BidirectionalDictionary<KeyType:Hashable, ValueType:Hashable>{
var keyToValue = [KeyType:ValueType]()
var valueToKey = [ValueType:KeyType]()
subscript(key:KeyType) -> ValueType? {
get {
return self.keyToValue[key]
}
set {
self.keyToValue[key] = newValue
@hdodov
hdodov / iframechange.js
Last active September 15, 2023 15:35
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
@jaskiratr
jaskiratr / chmod-400.cmd
Created June 29, 2018 01:03
Set permission of file equivalent to chmod 400 on Windows.
# Source: https://stackoverflow.com/a/43317244
$path = ".\aws-ec2-key.pem"
# Reset to remove explict permissions
icacls.exe $path /reset
# Give current user explicit read-permission
icacls.exe $path /GRANT:R "$($env:USERNAME):(R)"
# Disable inheritance and remove inherited permissions
icacls.exe $path /inheritance:r