Skip to content

Instantly share code, notes, and snippets.

View ieliwb's full-sized avatar
🌴
On vacation

ieliwb

🌴
On vacation
View GitHub Profile
@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 )
@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
@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),
@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
@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
@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
@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();
});
@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;
@wolf432
wolf432 / PHP中奖概率算法
Last active June 28, 2022 08:41
PHP中奖概率算法
<?php
/*
* 经典的概率算法,
* $proArr是一个预先设置的数组,
* 假设数组为:array(100,200,300,400),
* 开始是从1,1000 这个概率范围内筛选第一个数是否在他的出现概率范围之内,
* 如果不在,则将概率空间,也就是k的值减去刚刚的那个数字的概率空间,
* 在本例当中就是减去100,也就是说第二个数是在1,900这个范围内筛选的。
* 这样 筛选到最终,总会有一个数满足要求。
* 就相当于去一个箱子里摸东西,
@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>