project-folder/
.git
wp-admin/
wp-content/
wp-includes/
.htaccess
| const Page = require('puppeteer/lib/Page'); | |
| // the following 2 methods are originally from: https://github.com/GoogleChrome/puppeteer/issues/85#issuecomment-341743259, with some modification to fit puppeteerv1.0.0 | |
| async function newPageWithNewContext(browser) { | |
| const { browserContextId } = await browser._connection.send('Target.createBrowserContext'); | |
| const { targetId } = await browser._connection.send('Target.createTarget', { url: 'about:blank', browserContextId }); | |
| const target = await browser._targets.get(targetId); | |
| const client = await browser._connection.createSession(targetId); | |
| const page = await Page.create(client, target, browser._ignoreHTTPSErrors, browser._appMode, browser._screenshotTaskQueue); | |
| page.browserContextId = browserContextId; |
| // v3 is shorter than v2, and achieve same goal | |
| (()=>{ | |
| let Deferred = function(){ | |
| let resolver, rejector, | |
| promise = new Promise((resolve, reject)=>{ | |
| resolver = resolve; | |
| rejector = reject; | |
| }); | |
| promise.resolve = d=>resolver(d); | |
| promise.reject = d=>rejector(d); |
| //Knapsack algorithm | |
| //================== | |
| // wikipedia: [Knapsack (0/1)](http://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_Knapsack_Problem) | |
| // Given a set `[{weight:Number, benefit:Number}]` and a capacity, | |
| // find the maximum value possible while keeping the weight below | |
| // or equal to the capacity | |
| // **params**: | |
| // `capacity` : Number, | |
| // `items` : [{w:Number, b:Number}] | |
| // **returns**: |
| using System; | |
| namespace RsaKeyConverter.Converter | |
| { | |
| public static class BytesExtensions | |
| { | |
| public static string ToBase64(this byte[] bytes) | |
| { | |
| return Convert.ToBase64String(bytes); | |
| } |
| class Application { | |
| constructor() { | |
| this.middlewares = []; | |
| } | |
| use(func) { | |
| this.middlewares.push(func); | |
| } | |
| execute() { | |
| let stack = []; | |
| let idx = 0; |
| public static string GetBase64GifSpacer(int width, int height){ | |
| var bwidth = BitConverter.GetBytes(width); | |
| var bheight = BitConverter.GetBytes(height); | |
| var bytes = new byte[] { 0x47,0x49,0x46,0x38,0x39,0x61,bwidth[0],bwidth[1],bheight[0],bheight[1],0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xF9,0x04,0x01,0x00,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x00,bwidth[0],bwidth[1],bheight[0],bheight[1],0x00,0x02,0x02,0x44,0x01,0x00,0x3B }; | |
| return "data:image/gif;base64,"+Convert.ToBase64String(bytes); | |
| } |
| /// <summary> | |
| /// Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL. | |
| /// </summary> | |
| /// <typeparam name="T">Target Type, has to be a class type</typeparam> | |
| /// <param name="validator">An evaluation method, check if current alternative is valid as a return value.</param> | |
| /// <param name="that">The first alternative value</param> | |
| /// <param name="alternatives">Alternatives could be a value that is or can convert to target type; or a Func that return value as target type.</param> | |
| /// <returns>The first value that is not null (or white spaces for string) in arguments.</returns> | |
| public static T Coalesce<T>(this T that, Func<T, bool> validator, params object[] alternatives) where T : class | |
| { |
| using System; | |
| using System.Collections.Generic; | |
| /// <summary> | |
| /// Create a lock block against a string | |
| /// </summary> | |
| public class StringLocker | |
| { | |
| /// <summary> | |
| /// Store map from string to lockable object |
For more information, you can read a related blog post on this topic
You can now simply do:
# (turn on full debian repo; turn on ssh)
# be root
sudo su