Skip to content

Instantly share code, notes, and snippets.

View benbenbenbenbenben's full-sized avatar
🐶

Benjamin Babik benbenbenbenbenben

🐶
View GitHub Profile
%{
var indexed = [];
function log() {
console.log.apply(console, arguments);
}
function index(k, q) {
var i = k.indexOf(q);
if (i >= 0) {
if (typeof(k) === 'string')
indexed.push({ value: q, start: i, end: i + q.length });
/* lexical grammar */
%lex
%options case-insensitive
%%
\s+ /* skip whitespace */
\'[^']+\' return 'SQTERM'
\"[^"]+\" return 'DQTERM'
"and" return 'AND'
"or" return 'OR'
%{
Date.prototype.get_floor = function() {
return this.low_resolution
? new Date(this.getYear() + 1900, this.getMonth(), this.getDate())
: this;
}
Date.prototype.get_ceiling = function() {
return this.low_resolution
? new Date(this.getYear() + 1900, this.getMonth(), this.getDate(), 23, 59, 59, 999)
: this;
// 1. get browser
// 2. patch js
// 3. ???
// 4. profit
navigator.sayswho = (function(){
var ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
var Slots = (function(options) {
this.mode = 'x';
this.max = options.width;
if (options.height) {
this.mode = 'y';
this.max = options.height;
}
this.grid = 0;
this.items = [];
var Slots = require('./slots.js');
exports.slotsTests = {
irregularShapeDoesNotThrowWhenRotated: (test) => {
test.expect(2);
var s_h = new Slots({width:3});
var s_v = new Slots({height:3});
@benbenbenbenbenben
benbenbenbenbenben / login.cs
Last active August 6, 2022 20:22
how to login to microsoftonline.com/your.tenancy.xyz using WebRequest
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
void Main()
{
var file = @"someproject.csproj";
var dir = System.IO.Path.GetDirectoryName(file);
var proj = XDocument.Load(file);
var files = proj.Descendants().Where(p => p.Name.LocalName == "Content" && p.Attributes().Any(a => a.Name.LocalName == "Include"));
var toRemove = new List<XElement>();
// get a function's parameters as [...string]
(function() {
if (Function.prototype.parameters)
return;
Object.defineProperty(Function.prototype, "parameters", { get: function() {
var pattern = /^(?:(?:(?:function\s+[\w_\$][\w\d_\$]*)|function\s*|[\w_\$][\w\d_\$]*)(?:\(|[\w_\$])|\(|)(\s*(([\w_\$][\w\d_\$]*)([,\s]*)?)*)/gim
var matches = pattern.exec(this.toString())
return matches[1].split(',').map(s => s.trim()).filter(s => s.length)
}})
})()
[2018-01-07 12:30:04.731133]: Node starting, version: 9.0
[2018-01-07 12:30:04.732634]: Work pool running 4 threads
[2018-01-07 12:30:04.734634]: Starting bootstrap attempt
[2018-01-07 12:30:04.735134]: Bootstrap stopped because there are no peers
[2018-01-07 12:30:04.735134]: Exiting bootstrap attempt
[2018-01-07 12:30:12.761601]: UPnP local address: , discovery: 0, IGD search: 3
[2018-01-07 12:30:12.762104]: UPnP device url: http://192.168.1.1:1990/d4311ffc-9c6f-4028-89f7-c49bd6e7e090/WFADevice.xml st: upnp:rootdevice usn: uuid:abebceb4-eb14-2a04-c1c4-bc92c91503fb::upnp:rootdevice
[2018-01-07 12:30:12.769102]: UPnP TCP mapping verification response: -1, external ip response: -1, external ip: , internal ip: 0.0.0.0, remaining lease:
[2018-01-07 12:30:12.777111]: UPnP UDP mapping verification response: -1, external ip response: -1, external ip: , internal ip: 0.0.0.0, remaining lease:
[2018-01-07 12:30:12.780110]: UPnP TCP port mapping response: -4, actual external port