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
// Given large data payload with UTF-6 encoding, emojis etc. | |
const data = [{...}] | |
const string = JSON.stringify(data); // JSON to string | |
const byteArray = new TextEncoder().encode(string) // Convert to bytes | |
const deflatedByteArrayBuffer = zlib.deflateSync(byteArray); // Compress | |
const encoded = deflatedByteArrayBuffer.toString("base64url"); // Encode for safe transfer e.g. via URL | |
// URL-safe output | |
console.log(encoded) |
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
#!/usr/bin/env bash | |
#Fix starting screen setup issue https://github.com/getsentry/sentry/issues/12722 | |
echo "Set config.yml" | |
cat <<EOT > config.yml | |
auth.allow-registration: false | |
beacon.anonymous: true | |
mail.backend: 'smtp' | |
mail.from: "[email protected]" |
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
docker run \ | |
--name myadmin \ | |
--detach \ | |
--restart always \ | |
--link mysql:db \ | |
--publish 8080:80 \ | |
phpmyadmin/phpmyadmin:4.8.0.1 |
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
docker run \ | |
--detach \ | |
--restart always \ | |
--name redis \ | |
--publish 6379:6379 \ | |
redis:alpine |
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
using Newtonsoft.Json; | |
using React; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Umbraco.CMS.Helpers | |
{ | |
/// <summary> | |
/// Service helper to provide React Component config(s) required to hydrate on client-side |
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
<div ng-controller="Umbraco.PropertyEditors.ColorPickerController"> | |
<ul class="thumbnails color-picker"> | |
<li ng-repeat="preval in model.prevalues" ng-class="{active: model.value === preval.value}"> | |
<a ng-click="toggleItem(preval)" class="thumbnail" hex-bg-color="{{preval.color}}"> | |
</a> | |
<span class="color-label" ng-bind="preval.key"></span> | |
</li> | |
</ul> | |
<input type="hidden" name="modelValue" ng-model="model.value" val-property-validator="validateMandatory"/> |
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
/* Sometimes it's pretty easy to run ito troubles with React ES6 components. | |
Consider the following code: */ | |
class EventStub extends Component { | |
componentDidMount() { | |
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind | |
} | |
componentWillUnmount() { | |
window.removeEventListener('resize', this.onResize.bind(this)); |
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
_diffById(newArr, oldArr) { | |
function notContainedIn(arr) { | |
return function arrNotContains(element) { | |
return arr.map(el => { return el.id }).indexOf(element.id) === -1 | |
} | |
} | |
return { | |
added: newArr.filter(notContainedIn(oldArr)), | |
removed: oldArr.filter(notContainedIn(newArr)) | |
} |
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
docker run \ | |
--detach \ | |
--restart always \ | |
--name mongo \ | |
--publish 27017:27017 \ | |
--volume /Users/Charlie/Docker/Volumes/mongo-data:/data/db \ | |
--volume /Users/Charlie/Docker/Volumes/mongo-config:/data/configdb \ | |
mongo:3.4.14-jessie --auth | |
docker exec -it mongo mongo admin |
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
{ | |
"line1": "Cotton Court", | |
"line2": "Church Street", | |
"city": "Preston", | |
"region": "Lancashire", | |
"country": "United Kingdom", | |
"postcode": "PR1 3BY", | |
"timezone": "Europe/London", | |
"geopoint": { | |
"__type": "GeoPoint", |
NewerOlder