Skip to content

Instantly share code, notes, and snippets.

View ieliwb's full-sized avatar
🌴
On vacation

ieliwb

🌴
On vacation
View GitHub Profile
@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
);
@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] {
@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>
@wolf432
wolf432 / PHP中奖概率算法
Last active June 28, 2022 08:41
PHP中奖概率算法
<?php
/*
* 经典的概率算法,
* $proArr是一个预先设置的数组,
* 假设数组为:array(100,200,300,400),
* 开始是从1,1000 这个概率范围内筛选第一个数是否在他的出现概率范围之内,
* 如果不在,则将概率空间,也就是k的值减去刚刚的那个数字的概率空间,
* 在本例当中就是减去100,也就是说第二个数是在1,900这个范围内筛选的。
* 这样 筛选到最终,总会有一个数满足要求。
* 就相当于去一个箱子里摸东西,
@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;
@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();
});
@mayakraft
mayakraft / Kepler.m
Last active February 12, 2023 22:16
Keplerian Elements for Approximate Positions of the Major Planets
// http://ssd.jpl.nasa.gov/txt/aprx_pos_planets.pdf
typedef enum{
Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto
} Planet;
// a e I L long.peri. long.node.
// AU rad deg deg deg deg
static double elements[] = {0.38709927, 0.20563593, 7.00497902, 252.25032350, 77.45779628, 48.33076593, //mercury
0.72333566, 0.00677672, 3.39467605, 181.97909950, 131.60246718, 76.67984255, //venus
1.00000261, 0.01671123, -0.00001531, 100.46457166, 102.93768193, 0.0, //earth moon barycenter
@iggym
iggym / gist:6023041
Last active April 28, 2023 23:35
Apple iTunes Search API and RSS feeds. --- Apple very usefully provides unauthenticated json feeds for both the iTunes search and iTunes rss
Apple very usefully provides unauthenticated json feeds for both the iTunes search and iTunes rss
The Search API returns your search results in JavaScript Object Notation (JSON) format. JSON is built on two structures:
All JSON results are encoded as UTF-8. For more information on JSON, please see http://www.json.org.
---
Search API
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
---
RSS Info
@ck-on
ck-on / ocp.php
Last active May 18, 2024 22:35
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
@eagleon
eagleon / gist:1702129
Created January 30, 2012 02:35
阳历转农历PHP实现参考例子
<?php
class Lunar {
var $MIN_YEAR = 1891;
var $MAX_YEAR = 2100;
var $lunarInfo = array(
array(0,2,9,21936),array(6,1,30,9656),array(0,2,17,9584),array(0,2,6,21168),array(5,1,26,43344),array(0,2,13,59728),
array(0,2,2,27296),array(3,1,22,44368),array(0,2,10,43856),array(8,1,30,19304),array(0,2,19,19168),array(0,2,8,42352),
array(5,1,29,21096),array(0,2,16,53856),array(0,2,4,55632),array(4,1,25,27304),array(0,2,13,22176),array(0,2,2,39632),
array(2,1,22,19176),array(0,2,10,19168),array(6,1,30,42200),array(0,2,18,42192),array(0,2,6,53840),array(5,1,26,54568),
array(0,2,14,46400),array(0,2,3,54944),array(2,1,23,38608),array(0,2,11,38320),array(7,2,1,18872),array(0,2,20,18800),