Skip to content

Instantly share code, notes, and snippets.

View y-nk's full-sized avatar
🇹🇭
reviewing PRs

Julien Barbay y-nk

🇹🇭
reviewing PRs
View GitHub Profile
import { parse as parseAst } from "acorn";
import { load as parseYaml } from "js-yaml";
import { parse as parseToml } from "toml";
// stolen from remcohaszing/remark-mdx-frontmatter
const getValue = (node) => {
const { type, value } = node;
if (type === "yaml") {
return load(value);
// manually generate token for a given page (for when data is available in local)
generateTokenForPage(page: number): string {
return btoa(JSON.stringify({ skip: page * this.recordsPerPage, limit: this.recordsPerPage }));
}
AB1, AC4, AD10, BE3, CD4, CF2, DE1, EB3, EA2, FD1
@y-nk
y-nk / index.html
Created April 8, 2021 07:22
Gitlab environment variable filter by scope bookmarklet
<!--
how to use:
1. preview this page with: http://htmlpreview.github.io/
2. drag the link in your bookmarks bar
3. visit the page https://gitlab.com/xxxx/-/settings/ci_cd
4. click on the bookmarklet.
-->
<!DOCTYPE html>
<html lang="en">
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>myhostname.com</HostName>
<ReplaceKeyPrefixWith>#!/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
{
post: {
postId: 'postId',
data: {
images: [{
postId: 'childPost',
fileId: 'imageId',
}]
},
parentId: 'parentId',
const BadGoose = () => (<div>shown!</div>)
const App = (props) => {
const [toggle, setToggle] = useState(true)
return (<div>
<button onClick={() => setToggle(!toggle)}>click me</div>
{ toggle ? <BadGoose /> : null }
</div>)
}
const BadGoose = ({ show }) => (show ? <div>shown!</div> : null)
const App = (props) => {
const [toggle, setToggle] = useState(true)
return (<div>
<button onClick={() => setToggle(!toggle)}>click me</div>
<BadGoose show={toggle} />
</div>)
}
// import { isTouchEnable } from '../es6/functions.js';
/** Display autocomplete component on searches */
var Autocomplete = function(settings) {
this.settings = {
element: settings.element,
}
this.init();
@y-nk
y-nk / observable.js
Last active December 19, 2019 10:06
import { useState } from 'react'
export default (prop, value = null, context = {}) => {
const [val, setVal] = useState(value)
Object.defineProperty(context, prop, {
get() { return val },
set(val) { setVal(val) },
})