Skip to content

Instantly share code, notes, and snippets.

View adi518's full-sized avatar
🎯
Focusing

Adi adi518

🎯
Focusing
View GitHub Profile
@adi518
adi518 / bem.html
Created February 23, 2017 17:34 — forked from Integralist/bem.html
In CSS/BEM: how do we name a sub-block that is related to its parent block?
<!-- Simplest solution is to just label the element as a element within an element -->
<div class="block">
Content
<div class="block__element">
Content
<div class="block__element__element">
Content related to `block__element`
</div>
</div>
</div>
@adi518
adi518 / styles.less
Created April 26, 2017 23:43 — forked from brandondurham/styles.less
Using Operator Mono in Atom
/**
* Using Operator Mono in Atom
*
* 1. Open up Atom Preferences.
* 2. Click the β€œOpen Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called β€œstyles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
*
* Theme from the screenshot (http://cdn.typography.com/assets/images/blog/operator_ide2.png):
@adi518
adi518 / Uppercase.vue
Last active January 20, 2018 17:50 — forked from bengry/Uppercase.vue
// Uppercase.vue
<template>
<div>
<slot v-bind="{style: style}" />
</div>
</template>
<script>
export default {
data() {
@adi518
adi518 / package.json
Created March 28, 2018 15:53 — forked from ronapelbaum/package.json
PM Version Management Auto-Patch Gist
{
"name": "my-package",
"version": "1.2.0",
"scripts": {
"patch-version": "node patch-version.js",
"tag-version": "node tag-version.js \"release-tag\"",
"prerelease": "npm run patch-version && npm run tag-version",
"release": "npm publish",
}
}
@adi518
adi518 / gist:a8be5e1b436648776da8d2e886f735ab
Created June 16, 2018 13:16 — forked from snowman-repos/gist:3825198
JavaScript: Detect Orientation Change on Mobile Devices
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
alert(window.orientation);
}, false);
// Listen for resize changes
window.addEventListener("resize", function() {
// Get screen size (inner/outerWidth, inner/outerHeight)
@adi518
adi518 / what-forces-layout.md
Created July 13, 2018 23:50 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@adi518
adi518 / webkit-pseudo-elements.md
Created January 9, 2019 19:31 — forked from leostratus/webkit-pseudo-elements.md
Webkit Pseudo-Element Selectors (Shadow DOM Elements)

An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.

Everything is broken up by tag, but within each the selectors aren't particularly ordered.

I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A

A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:

-webkit-appearance:none;

@adi518
adi518 / regexCheatsheet.js
Created January 12, 2019 19:08 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet πŸ‘©πŸ»β€πŸ’» (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@adi518
adi518 / download-file.js
Created May 26, 2019 21:47 — forked from zynick/download-file.js
download file ('save as') using javascript xhr
// http://stackoverflow.com/a/23797348/1150427
xhr.open('POST', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
if (this.status === 200) {
var filename = "";
var disposition = xhr.getResponseHeader('Content-Disposition');
if (disposition && disposition.indexOf('attachment') !== -1) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
@adi518
adi518 / get_git_branch_sha.sh
Created June 25, 2019 12:04 — forked from scottwb/get_git_branch_sha.sh
Get the SHA of some git branch.
# Get the SHA of some branch. There must be a better way to do this.
git log -1 --pretty=oneline origin/somebranch | sed -E "s/^([^[:space:]]+).*/\1/"