Skip to content

Instantly share code, notes, and snippets.

View imedadel's full-sized avatar
🏗️
Building something

Imed Adel imedadel

🏗️
Building something
View GitHub Profile
@imedadel
imedadel / SassMeister-input.scss
Created August 20, 2018 05:17
Precise control over responsive typography for Sass
// ----
// libsass (v3.5.0.beta.2)
// ----
// =========================================================================
//
// PRECISE CONTROL OVER RESPONSIVE TYPOGRAPHY FOR SASS
// ---------------------------------------------------
// Indrek Paas @indrekpaas
//
/*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%
}
body {
margin: 0
}
[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((+{}+[])[+!![]]+(![]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]+[][(![]+[])[!+[]+!![]+!![]]+([]+{})[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]][([]+{})[!+[]+!![]+!![]+!![]+!![]]+([]+{})[+!![]]+([][[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+([]+{})[+!![]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([][[]]+[])[+[]]+([][[]]+[])[+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(![]+[])[!+[]+!![]+!![]]+([]+{})[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
def get_node_order(self, node):
return self.nodes.index(node)
def subgraph(self, nbunch, name=None):
nbunch = (n.node_id for n in nbunch)
return DmSubgraph(self._graph.subgraph(nbunch), name)
def get_root_nodes(self):
return [n['id'] for n in self.graph.nodes()]
def get_nodes(self):
return self._graph.nodes()
@imedadel
imedadel / index.js
Created May 26, 2019 09:06
An example of using React Hooks with jQuery and Chosen plugin. `Chosen` is the original example using a class and `Chosed` is the "modern" approach using functions and hooks.
const Chosed = (props) => {
const elmt = React.useRef()
React.useLayoutEffect(()=>{
const $elmt = $(elmt.current)
const handleChange = (e) => {
props.onChange(e.target.value);
}
$elmt.chosen()

Quickly rename anything using Git Bash through this command find . -name "*.gappedPeak" -exec sh -c 'mv "$1" "${1%.gappedPeak}.bed"' _ {} \;

const bigN = 13
const alphas = 26
const lowerCaseA = 'a'.charCodeAt(0)
const upperCaseA = 'A'.charCodeAt(0)
const rotate = str => str
.normalize('NFD')
.split('')
.map(chr => chr.charCodeAt(0))
.map(charCode =>
(lowerCaseA <= charCode && charCode < lowerCaseA + alphas) ? ((charCode - lowerCaseA + bigN) % alphas) + lowerCaseA :
@imedadel
imedadel / gist:d6fed5d052ffa70be3ca11e95af4fd6d
Created July 7, 2019 22:05 — forked from amad-person/gist:f0ef85a2123a2e1fcf8052dcf09eef90
Bypass CSP restrictions in create-react-app Chrome extensions

While building a React Chrome extension using the create-react-app utility (v2.x), I came across the following error on loading my unpacked extension:

Refused to execute inline script because it violates the following Content Security Policy directive: “script-src ‘self’
blob: filesystem: chrome-extension-resource:”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-
GgRxrVOKNdB4LrRsVPDSbzvfdV4UqglmviH9GoBJ5jk=’), or a nonce (‘nonce-…’) is required to enable inline execution.

Basically, this error arises as Chrome (or almost any modern browser) will not allow inline scripts to get executed. This CSP restriction resulted in the above error as the build script in create-react-app bundles the .js files in <script> tags in the <body> of index.html.

const parser = require("@babel/parser")
const generator = require("@babel/generator")
const code = 'module.exports = { j: "h"}'
const ast = parser.parse(code)
generator.default(ast, {}).code