Skip to content

Instantly share code, notes, and snippets.

View getExternalIpAddress.js
#!/usr/bin/env gjs
const { GLib, GUPnP } = imports.gi;
const { MainLoop } = GLib;
const mainloop = new MainLoop(null, true);
function getExternalIpAddress() {
// does it work with interface: null or without
View steam-sys-info.txt
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
CPU Family: 0x6
View gist:de602cfc5878fa2f5c49b16fdb0a7c87
LD_PRELOAD=/usr/lib64/libfreetype.so.6 %command%
View csi.js
import {AppState} from 'react-native';
import xml from './xmpp/packages/xml';
// https://xmpp.org/extensions/xep-0352.html
// https://facebook.github.io/react-native/docs/appstate
module.exports = function csi({entity}) {
let supported = false;
let inactive = false;
@sonnyp
sonnyp / set-power-uuid.sh
Created Sep 27, 2019 — forked from andrew-d/set-power-uuid.sh
Bash script to set INT3400 Thermal zone power profile
View set-power-uuid.sh
#!/bin/bash
set -eu
die() {
echo "$1" >&2
exit 1
}
@sonnyp
sonnyp / promise-event.js
Created May 27, 2017
promise event from EventEmitter
View promise-event.js
class TimeoutError extends Error {}
function promise (event, timeout) {
return new Promise((resolve, reject) => {
let timer
const cleanup = () => {
this.removeListener(event, onEvent)
this.removeListener('error', onError)
clearTimeout(timer)
}
View urlEncode.js
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, (c) => {
return `%${c.charCodeAt(0).toString(16)}`;
});
}
function urlEncode(params) {
let data = '';
Object.keys(params).forEach((key, idx, { length }) => {
const k = fixedEncodeURIComponent(key.toString());
@sonnyp
sonnyp / bind.xml
Created Jun 6, 2016
prosody bind issue
View bind.xml
<!-- OUT -->
<iq to="localhost" type="set" id="40924263533590377" xmlns="jabber:client">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
</iq>
<!-- IN -->
<iq id="40924263533590377" type="error" xmlns="jabber:client" from="localhost">
<error type="cancel">
<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
@sonnyp
sonnyp / iife.js
Last active Apr 13, 2016
JavaScript IIFE for Node.js and browsers
View iife.js
// global will refer to global for Node.js and window for browsers
;(function (global) { // ; in case the file is concatenated with a non ; line ending
'use strict'
// your code
}(typeof global !== 'undefined' ? global : this)) // `this`doesn't refer to global in Node.js module
View .editorconfig
# EditorConfig is awesome: http://EditorConfig.org
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = space