NSMutableArray *installed = [NSMutableArray array];
NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary];
NSArray *whitelistSchemes = infoPlist[@"LSApplicationQueriesSchemes"];
for(NSString *scheme in whitelistSchemes) {
NSURL *url = [NSURL URLWithString: [scheme stringByAppendingString: @"://"]];
if([[UIApplication sharedApplication] canOpenURL: url]) {
[installed addObject: scheme];
}
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sourceDomain = 'blog.shapo.io'; | |
async function handleRequest(request) { | |
const parsedUrl = new URL(request.url) | |
console.log('url:', request.url, 'parsed:', parsedUrl.toString()); | |
// if its blog html, get it | |
if(parsedUrl.pathname.includes('/blog')) { | |
parsedUrl.hostname = sourceDomain; | |
parsedUrl.pathname = parsedUrl.pathname.replace('/blog', ''); | |
console.log('requesting:', parsedUrl.toString()); | |
const response = await fetch(parsedUrl, request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const captchaApiKey = 'API_KEY'; | |
async function solveCaptcha(page, { userAgent, proxy }) { | |
const hasCaptcha = await page.waitForSelector('#recaptcha', { timeout: 5000 }).catch(() => {}); | |
if(!hasCaptcha) { | |
return { hasCaptcha }; | |
} | |
captchaSolver.setApiKey(captchaApiKey); | |
// eslint-disable-next-line no-underscore-dangle | |
const { cookies } = await page._client.send('Network.getAllCookies'); | |
const cookiesString = captchaSolver.cookiesToString(cookies); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (obj) => { | |
const entries = Object.entries(obj); | |
return Promise | |
.all(entries.map(([, v]) => v)) | |
.then(results => results | |
.reduce((accumulator, value, idx) => { | |
const [key] = entries[idx]; | |
accumulator[key] = value; | |
return accumulator; | |
}, {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const Schema = mongoose.Schema; | |
const schema = new Schema({ | |
item: { | |
type: String, | |
set: function(item) { | |
console.log('item setter called') | |
return normalize(item); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const Schema = mongoose.Schema; | |
const schema = new Schema({ | |
strings: { | |
type: [String], | |
default: () => void 0, | |
required: true, | |
set: function(items) { | |
console.log('strings setter called'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(int j = 0 ; j < ships[i].getLength() ; j ++) { | |
switch(direct) { | |
case vertical: | |
board[row + j][col] = 'S'; | |
break; | |
case horizontal: | |
board[row][col + j] = 'S'; | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
<!--<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />--> | |
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
<uses-permission android:name="android.permission.WAKE_LOCK" /> | |
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> | |
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> | |
<permission android:name="com.natanavra.killsilentmode.permission.C2D_MESSAGE" | |
android:protectionLevel="signature" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Object drillJSONObject(JSONObject obj, String path) throws JSONException { | |
if(path == null) { | |
return null; | |
} else if(path.length() == 0) { | |
return null; | |
} | |
Object jumper = obj; | |
String[] components = path.split("\\."); //Dots specifically not regex any char. | |
for(String component : components) { |