Skip to content

Instantly share code, notes, and snippets.

View just-jeb's full-sized avatar
🌐

JeB just-jeb

🌐
View GitHub Profile
@just-jeb
just-jeb / embed-gist-dark-theme.css
Last active May 23, 2026 07:05
Dark theme gist embed for blog
<style>
/* https://github.com/lonekorean/gist-syntax-themes */
@import url('https://cdn.rawgit.com/lonekorean/gist-syntax-themes/d49b91b3/stylesheets/idle-fingers.css');
@import url('https://fonts.googleapis.com/css?family=Open+Sans');
body {
font: 16px 'Open Sans', sans-serif;
}
body .gist .gist-file {
border-color: #555 #555 #444
@just-jeb
just-jeb / use-state-callback.tsx
Last active September 2, 2020 19:10
useState and callbacks
const [array, setArray] = useState([]);
// Good
const addValue = (value) =>
setArray(prevArray => [...prevArray, value])
// Bad, this is closure
const addValue = (value) =>
setArray([...array, value])
{
"name": "Great Extension",
"version": "1.0",
"description": "Build an Extension with Angular",
"manifest_version": 2
}
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.sync.set({ color: '#3aa757' });
chrome.webNavigation.onCompleted.addListener(() => {
chrome.tabs.query({ active: true, currentWindow: true }, ([{ id }]) => {
if (id) {
chrome.pageAction.show(id);
}
});
}, { url: [{ urlMatches: 'google.com' }] });
ngOnInit(): void {
chrome.storage.sync.get('color', ({ color }) => {
this.color = color;
});
}
<span [style.color]="color"
[cpToggle]="true"
[cpDialogDisplay]="'inline'"
[cpPositionRelativeToArrow]="true"
[(colorPicker)]="color"
[cpOKButtonText]="'Apply'"
[cpOKButton]="true"
(colorPickerChange)="updateColor($event)"
(colorPickerSelect)="colorize()">
</span>
{
"name": "Great Extension",
"version": "1.0",
"description": "Build an Extension with Angular",
"manifest_version": 2,
"permissions": [
"activeTab",
"webNavigation",
"storage"
],
<span [style.color]="color"
[cpToggle]="true"
[cpDialogDisplay]="'inline'"
[cpPositionRelativeToArrow]="true"
[(colorPicker)]="color"
[cpOKButtonText]="'Apply'"
[cpOKButton]="true"
(colorPickerSelect)="colorize()">
</span>
export class AppComponent {
color = '#ffffff';
public colorize() {
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
chrome.tabs.executeScript(
tabs[0].id!,
{ code: `document.body.style.backgroundColor = '${ this.color }';` }
);
});
body {
margin: 0;
}