Skip to content

Instantly share code, notes, and snippets.

const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('ipc', {
submit: (channel, ...data) => {
console.log('api send');
const validChannels = ['toMain'];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, ...data);
}
},
import React, { Component, createRef, useEffect, useState } from "react";
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
const Modal = (props) => {
// console.log(props);
const [show, setShow] = useState(false);
@sillyslux
sillyslux / getAll.js
Created October 22, 2020 15:28
try here https://swapi.dev/ with your browser console
async function getAll () {
let cont = true;
let page = 1;
let ret = [];
while(cont) {
const moreShips = await fetch("https://swapi.dev/api/starships/?page="+page).then(r => r.json());
if (!moreShips.next) cont = false;
page = page + 1;
ret = [...ret, moreShips];
}
@sillyslux
sillyslux / userContent.css
Created July 7, 2020 15:11
firefox theme file to follow system theme in devtools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* IMPORTANT NOTE
* This file is parsed in js (see client/shared/theme.js)
* so the formatting should be consistent (i.e. no '}' inside a rule).
*/
@sillyslux
sillyslux / map.js
Last active May 1, 2020 14:34 — forked from Franckapik/map.js
let playersList = {};
listeId.map((ident, i) => {
playersList[ident] = {
score : 0,
x : 0,
y : 0
}
})
const playersList = listeId.reduce( (p, c) => ({ ...p, [c]: { score: 0, x: 0 , y:0 } }), {});
@sillyslux
sillyslux / custom-dyndns
Created March 2, 2020 17:50
changeip update script
#!/bin/sh
#
# /etc/network/if-up.d/custom-dyndns
#
# Update dynamic dns provider changeip.com.
#
# Create a link with:
# `sudo ln ~/.bin/changeipcom /etc/network/if-up.d/custom-dyndns`
#
# Save your sensitive data in /root/secrets:
@sillyslux
sillyslux / windowmenu
Created February 18, 2020 14:40
fluxbox windowmenu
[begin] (windowmenu)
[submenu] (half)
[MacroCmd {ResizeTo 50% 100%} {MoveTo 0 0 TopLeft}] (T) <~/.icons/custom/half-left.png>
[MacroCmd {ResizeTo 50% 100%} {MoveTo 0 0 TopRight}] (T) <~/.icons/custom/half-right.png>
[MacroCmd {ResizeTo 100% 50%} {MoveTo 0 0 TopLeft}] (T) <~/.icons/custom/half-top.png>
[MacroCmd {ResizeTo 100% 50%} {MoveTo 0 0 BottomLeft}] (T) <~/.icons/custom/half-bottom.png>
[end]
[submenu] (thirds)
[MacroCmd {ResizeTo 100% 66%} {MoveTo 0 0 TopLeft}] (T) <~/.icons/custom/thirds-top.png>
[MacroCmd {ResizeTo 100% 33%} {MoveTo 0 0 TopLeft}] (T) <~/.icons/custom/third-top.png>
// ==UserScript==
// @name jsfiddle auto dark switch
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @include https://jsfiddle.net/*
// @grant none
// ==/UserScript==
@sillyslux
sillyslux / someComponent.jsx
Last active October 9, 2019 12:24
win/mac/linux theme change listener for react
import React from 'react';
import { themeChange } from '../../../style/theme';
...
themeChange.subscribe(console.log); // logs dark/light