//// What is TypeScript?
// ts is super set of js
// + types
// + typecheck
// + transpiler(like babel)
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
<? | |
header('Content-Type: text/plain'); | |
function chmod_r($dir) | |
{ | |
$dp = opendir($dir); | |
while($file = readdir($dp)) | |
{ | |
if (($file == ".") || ($file == "..")) continue; |
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
<?php | |
class SiteOrigin_Widget_InlineCSS extends SiteOrigin_Widget { | |
function generate_and_enqueue_instance_styles($instance) { | |
if(empty($this->form_options)) $this->form_options = $this->initialize_form(); | |
if(empty($instance)) return; | |
$instance = $this->add_defaults($this->form_options, $instance); | |
$css_name = $this->id_base . '-' . $this->get_style_name($instance) . '-' . $this->get_style_hash($instance); | |
$css = wp_cache_get($css_name, 'siteorigin_widgets'); |
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
new class { | |
constructor() { | |
this.nodes = this.find('.position_sticky').map(el => { return { el, placeholder: null } }) | |
window.addEventListener('scroll', e => this.go(), { passive: true }) | |
this.go() | |
} | |
go() { | |
this.nodes.forEach(node => this.check(node)) | |
} |
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
<?php | |
if(get_current_user_id() == 1) { | |
$ids = get_all_page_ids(); | |
foreach($ids as $id) { | |
$data = get_post_meta($id, 'panels_data'); | |
if(!$data) { continue; } | |
$data = $data[0]; | |
foreach($data['widgets'] as $key => $widget) { | |
if($widget['panels_info']['class'] == 'old_class') { | |
$data['widgets'][$key]['panels_info']['class'] = 'new_class'; |
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
export function createState(reducer) { | |
const State = createContext([]) | |
function getInitialState() { | |
return reducer(undefined, { type:"@@INIT" }) | |
} | |
function StateProvider({ children }) { | |
return createElement(State.Provider, { value: useReducer(reducer, undefined, getInitialState), children }) | |
} |
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
try { | |
main() | |
} catch (e) { | |
document.body.textContent = "" | |
create(document.body, "h1", "m-3").textContent = "😔" | |
create(document.body, "pre", "m-3").textContent = e | |
throw e | |
} | |
function main() { |
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
declare const Elm: Elm | |
interface Elm { | |
Main: AppConstructor<unknown, { port1: SubscribePort<unknown>; port2: SendPort<unknown> }> | |
} | |
interface AppConstructor<Flags, Ports> { | |
init(options: { node?: HTMLElement; flags: Flags }): { ports: Ports } | |
} |
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
export type List<A> = Array<A> | |
export type Maybe<A> = A | null | |
export type Cmd<Msg> = Maybe<(_: sendMsg<Msg>) => void> | |
type updateFn<Msg, Model> = (_: Msg) => (_: Model) => [Model, Cmd<Msg>] | |
type sendMsg<Msg> = (_: Msg) => void | |
export let elmTsRuntime: <Msg, Model>(_: [Model, Cmd<Msg>]) => (_: updateFn<Msg, Model>) => void | |
elmTsRuntime = ([model, cmd]) => update => { | |
const sendMsg = (msg: any) => { |
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
export function app<Msg, Model>(model: Model, updateFn: (msg: Msg, model: Model) => Model) { | |
return (msg: Msg) => { | |
defer(() => { | |
model = updateFn(msg, model) | |
}) | |
} | |
} | |
export function defer(fn: () => void): void { | |
Promise.resolve().then(fn) |
OlderNewer