Skip to content

Instantly share code, notes, and snippets.

@anandsunderraman
anandsunderraman / setChromeOptions.js
Last active May 2, 2024 05:54
Selenium Web Driver Set Chrome Options
//import the selenium web driver
var webdriver = require('selenium-webdriver');
var chromeCapabilities = webdriver.Capabilities.chrome();
//setting chrome options to start the browser fully maximized
var chromeOptions = {
'args': ['--test-type', '--start-maximized']
};
chromeCapabilities.set('chromeOptions', chromeOptions);
var driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build();
@steven-michaud
steven-michaud / ThirdPartyKexts.md
Last active May 2, 2024 05:54
Running Third Party Kernel Extensions on Virtualization Framework macOS Guest VMs

Running Third Party Kernel Extensions on Virtualization Framework macOS Guest VMs

As of macOS 12 (Monterey), Apple's Virtualization framework has nice support for macOS guest virtual machines, but with severe limitations: For example you can't install a macOS guest on Intel Macs, install guests with newer versions of macOS than the host, copy and paste between the host and the guest, or install third party kernel extensions in the guest. As usual for Apple, the functionality they do support is nicely implemented, but they've left out so much that the result is only marginally useful -- at least compared to

AR.json: "validation_regex": "([A-HJ-NP-Z])?\\d{4}([A-Z]{3})?"
AR.json: "validation_regex": "([A-HJ-NP-Z])?\\d{4}([A-Z]{3})?"
BE.json: "validation_regex": "[1-9]\\d{3}"
BE.json: "validation_regex": "[1-9]\\d{3}"
BN.json: "validation_regex": "[A-Z]{2}[ ]?\\d{4}"
BN.json: "validation_regex": "[A-Z]{2}[ ]?\\d{4}"
BR.json: "validation_regex": "\\d{5}[\\s\\-]?\\d{3}"
BR.json: "validation_regex": "\\d{5}[\\-]?\\d{3}"
CA.json: "validation_regex": "[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJ-NPRSTV-Z][ ]?\\d[ABCEGHJ-NPRSTV-Z]\\d"
CA.json: "validation_regex": "[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJ-NPRSTV-Z][ ]?\\d[ABCEGHJ-NPRSTV-Z]\\d"
@barneycarroll
barneycarroll / rest_spread.js
Created November 24, 2022 19:23
WIP for a little demonstration of the various functions of ... operators in Javascript
const object = {a: 1, b: 2}
const array = [3,4]
// Value expression
const foo = {...object, c: 3} // == {a: 1, b: 2, c: 3}
const bar = [...array, 5, 6] // == [3, 4, 5, 6]
// Destructuring assignment
{
const {a, ...rest} = foo // a == {a: 1}; rest == {b: 2, c: 3}
@barneycarroll
barneycarroll / disable-zoom.js
Created April 3, 2024 06:17
Selectively disable mobile browser zoom on input focus
// Disable mobile zoom on focus
{
// Customise the selector value as necessary
const selector = '[data-nozoom]'
const $viewport =
document.querySelector('meta[name=viewport]')
??
Object.assign(document.createElement('meta'), {name: 'viewport'})
const $scale0 = Object.assign($viewport.cloneNode(), {content: 'user-scalable=0'})
@barneycarroll
barneycarroll / .js
Created July 27, 2022 10:55
Using modules not components for associated functionalities, with state management left to application space
import {ordinals, defaultRange, rangeFromOrdinal, Calendar} from './DateRange.js'
const state = {
...rangeFromOrdinal('Today'),
showCalendar : false,
}
m.mount(document.body, {
view: () => [
m('form',
@barneycarroll
barneycarroll / ordinal-suffix.html
Created March 19, 2014 13:35
Append ordinals via CSS rather than in markup. Requires even more HTML bytes though.
<span
class="ordinal"
data-number="22">
22
</span>
<span
class="ordinal"
data-number="0">
0
</span>
@ajaxray
ajaxray / ToArrayExtension.php
Last active May 2, 2024 05:51
A simple twig extension that adds a to_array filter. It will convert an object to array so that you can iterate over it's properties
<?php
// src/YourApp/Bundle/YourBundle/Twig/ToArrayExtension.php
namespace Appcito\Bundle\CoreBundle\Twig;
/**
* A simple twig extension that adds a to_array filter
* It will convert an object to array so that you can iterate over it's properties
*/
class ToArrayExtension extends \Twig_Extension
@ajaxray
ajaxray / backbone_tide_sync.js
Last active May 2, 2024 05:51
Overridden Backbone.sync to use SQLite (in tidesdk) instead of REST. So far "read" is completed.
Backbone.sync = function(method, model, options) {
// App.db is my database connection
if(_.isNull(App.db)) console.error('No Database connection!');
var query = BackboneDb.createQuery(method, model, options);
if (method === "read") {
var data = App.db.execute(query);
var resultJSON = BackboneDb.resultToJSON(data);
console.log(resultJSON);
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: