Skip to content

Instantly share code, notes, and snippets.

View dive2Pro's full-sized avatar
:shipit:
Sticking

dive2Pro

:shipit:
Sticking
  • 中国-深圳
View GitHub Profile
@seanwoodward
seanwoodward / ContactPickerButton.swift
Last active May 27, 2024 03:31
Using CNContactPickerViewController from SwiftUI View
import SwiftUI
import Contacts
import ContactsUI
struct SomeView: View {
@State var contact: CNContact?
var body: some View {
VStack {
Text("Selected: \(contact?.givenName ?? "")")
@LuisThiamNye
LuisThiamNye / days_until_widget.cljs
Created May 22, 2021 10:53
Roam/Render component for showing the days until a date.
(ns com.luisthiamnye.roam-render.days-until
(:require
[roam.datascript :as d]
[clojure.string]))
(defn inherited-uids [uid]
(d/q '[:find [?uids ...]
:in $ ?uid
:where
[?b :block/uid ?uid]
@LuisThiamNye
LuisThiamNye / roam_stats_comp.cljs
Last active July 18, 2022 15:35
Roam Statistics MVP
(ns roam-stats
(:require
[roam.datascript :as d]
[clojure.string]
[reagent.core :as r]))
(defn string-bytes [s]
(.-size (js/Blob. [s])))
(defn total-pages []
@dbieber
dbieber / roam-unlinked-references-query.js
Last active July 23, 2022 03:04
Roam Research datalog query for references not already placed on a specific page
let container = "Tree of knowledge";
let tag = "zettel";
let ancestorrule=`[
[(ancestor ?child ?parent)
[?parent :block/children ?child]]
[(ancestor ?child ?a)
[?parent :block/children ?child]
(ancestor ?parent ?a)]
]`;
@Soheab
Soheab / API's.md
Last active July 18, 2024 23:23
See here some of the API's you can use in your discord bot or anything

Some API's for you.

See here some of the API's you can use in your discord bot or anything. For any help or questions on how to use one, please contact the owner of the API and not me.

A much bigger list of APIs can be found here


[TOKEN] = API requires a token to access some if not all endpoints.

The descriptions are mostly copied from the API, sometimes personal or from the dev.

@myshov
myshov / function_invocation.js
Last active January 21, 2024 15:14
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);

tracked npm

@tracked is a decorator for Preact that makes working with state values no different than properties on your component instance.

It's one 300 byte function that creates a getter/setter alias into state/setState() for a given key, with an optional initial value. The "magic" here is simply that it works as a property decorator rather than a function, so it appears to integrate directly into the language.

tracked has no dependencies and works with any component implementation that uses this.state and this.setState().

Installation

@joshcanhelp
joshcanhelp / scrollTo.js
Last active January 28, 2022 13:21
Animated scrollTo for specific element or top of page
//
// Smooth scroll-to inspired by:
// http://stackoverflow.com/a/24559613/728480
//
module.exports = function (scrollTo, scrollDuration) {
//
// Set a default for where we're scrolling to
//
@yamadayuki
yamadayuki / SampleComponent.js
Created June 19, 2016 14:58
Use keyframes property with React using inline style
import React from 'react';
import injectStyle from './path/to/injectStyle';
export default class SampleComponent extends React.Component {
constructor(props) {
super(props);
const keyframesStyle = `
@-webkit-keyframes pulse {
0% { background-color: #fecd6d; }
@tejacques
tejacques / HOCBaseRender.tsx
Last active May 2, 2022 13:05
React Higher Order Components in TypeScript
import * as React from 'react';
import { Component } from 'react';
export default function HOCBaseRender<Props, State, ComponentState>(
Comp: new() => Component<Props & State, ComponentState>) {
return class HOCBase extends Component<Props, State> {
render() {
return <Comp {...this.props} {...this.state}/>;
}
}