Skip to content

Instantly share code, notes, and snippets.

View ieliwb's full-sized avatar
🌴
On vacation

ieliwb

🌴
On vacation
View GitHub Profile
@ruandao
ruandao / QRScannerViewController.h
Created June 7, 2014 09:12
二维码扫描 iOS7 && iOS 7 以上
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@protocol QRScannerViewControllerDelegate <NSObject>
- (void) catch:(NSString*)content;
@end
@interface QRScannerViewController : UIViewController
@property (assign, nonatomic) id<QRScannerViewControllerDelegate> delegate;
@jerrybendy
jerrybendy / filter_relative_url.php
Last active July 6, 2018 10:18
PHP转换网址相对路径到绝对路径的一种方法 https://icewing.cc/php-conv-addr-re-ab-2.html
/**
* 把从HTML源码中获取的相对路径转换成绝对路径
* @param string $url HTML中获取的网址
* @param string $URI 用来参考判断的原始地址
* @return 返回修改过的网址,如果网址有误则返回FALSE
*/
function filter_relative_url($url, $URI){
//STEP1: 先去判断URL中是否包含协议,如果包含说明是绝对地址则可以原样返回
if(strpos($url, '://') !== FALSE){
return $url;
@ufologist
ufologist / ios-body-click-bubble-bug.html
Created September 19, 2017 09:06
iOS body click 事件冒泡的 bug
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>iOS body click 事件冒泡的 bug</title>
</head>
<body>
<h1>点击 h1 不会冒泡到 body</h1>
@zats
zats / README.md
Last active July 2, 2019 10:45
UIPreviewActionItem for SFSafariViewController through delegation not subclassing

Adding UIPreviewActionItem to SFSafariViewController might be a tedious task. This extansion should help.

let vc = SFSafariViewController(initialURL: url, entersReaderIfAvailable: true)
vc.previewActionItemsDelegate = self

When presenting SFSafariViewController use convenience initializer that will store original URL for later, it'll make custom action requiring original URL easier. But it's not mandatory.

Here is the delegate implementation, this is where we might want to use initialURL

func safariViewControllerPreviewActionItems(controller: SFSafariViewController) -> [UIPreviewActionItem] {
@grahampcharles
grahampcharles / autosubmit.js
Created March 5, 2014 23:09
jquery function to automatically submit a form each time a control is changed
/*
Usage:
Add a class of "autosubmit" to controls. If the control is not within a form
(or even if it is but you want to use a different form), add data-autosubmit-form="#selector".
Then, on DOM ready, execute autosubmit() to wire up the handlers:
$(function () {
autosubmit();
});
@shadowbrain
shadowbrain / parse json with sed
Created December 16, 2011 15:32
parse json key:value with sed
## Example: Grab the value for the MYSQL_USER key
User=$( sed -n 's/.*"MYSQL_USER": "\(.*\)",/\1/p' /var/lib/credentials.json )
## Example: Grab the value for the MYSQL_PASSWORD key
Passwd=$( sed -n 's/.*"MYSQL_PASSWORD": "\(.*\)",/\1/p' /var/lib/credentials.json )
@alexwilson
alexwilson / cloudflare-challenge.js
Last active September 3, 2021 17:23
This is a project designed to get around sites using Cloudflare's "I'm under attack" mode. Using the PhantomJS headless browser, it queries a site given to it as the second parameter, waits six seconds and returns the cookies required to continue using this site. With this, it is possible to automate scrapers or spiders that would otherwise be t…
/**
* This is a project designed to get around sites using Cloudflare's "I'm under attack" mode.
* Using the PhantomJS headless browser, it queries a site given to it as the second parameter,
* waits six seconds and returns the cookies required to continue using this site. With this,
* it is possible to automate scrapers or spiders that would otherwise be thwarted by Cloudflare's
* anti-bot protection.
*
* To run this: phantomjs cloudflare-challenge.js http://www.example.org/
*
* Copyright © 2015 by Alex Wilson <antoligy@antoligy.com>
//
// PHPhotoLibrary+CustomPhotoAlbum.h
// dashcam_ios
//
// Created by hc on 2016/11/25.
// Copyright © 2016年 Sunvalley. All rights reserved.
//
#import <Photos/Photos.h>
@rwest
rwest / README
Created January 9, 2012 16:42 — forked from symposion/README
Convert OS X Keychain exported entries into logins for 1Password import
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
@dmitriynet
dmitriynet / php
Created November 20, 2015 10:05
mb_unserialize
function mb_unserialize($string)
{
$recovered = preg_replace_callback(
'!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|d:|i:|o:|N;))!s',
function($match) {
return 's:' . mb_strlen($match[2], '8bit');
},
$string
);