Skip to content

Instantly share code, notes, and snippets.

View sekmet's full-sized avatar
📡
If you are going to TRY, go ALL the WAY!

Carlos Guimaraes sekmet

📡
If you are going to TRY, go ALL the WAY!
View GitHub Profile
@sekmet
sekmet / gist:7c6888e9b9fa15b47910838e2b5a0daa
Created June 19, 2020 00:51 — forked from dandelany/gist:1ff06f4fa1f8d6f89c5e
Recursively cloning React children
var RecursiveChildComponent = React.createClass({
render() {
return <div>
{this.recursiveCloneChildren(this.props.children)}
</div>
},
recursiveCloneChildren(children) {
return React.Children.map(children, child => {
if(!_.isObject(child)) return child;
var childProps = {someNew: "propToAdd"};
@sekmet
sekmet / plink-plonk.js
Created February 16, 2020 06:26 — forked from tomhicks/plink-plonk.js
Listen to your web pages
@sekmet
sekmet / web-servers.md
Created January 19, 2020 17:54 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@sekmet
sekmet / slugify.php
Created November 20, 2019 19:56
slugify php function - pt_br
function slugify($string) {
$string = preg_replace('/[\t\n]/', ' ', $string);
$string = preg_replace('/\s{2,}/', ' ', $string);
$list = array(
'Š' => 'S',
'š' => 's',
'Đ' => 'Dj',
'đ' => 'dj',
'Ž' => 'Z',
'ž' => 'z',
@sekmet
sekmet / gatsby-node.js
Created September 26, 2019 18:39 — forked from henrikwirth/gatsby-node.js
Extending WP GraphQL images with gatsby-image functionality
const { createRemoteFileNode } = require(`gatsby-source-filesystem`)
// Note that WPGraphQL_MediaItem depends on your gatsby-source-graphql typeName which is set in the config
exports.createResolvers = ({
actions,
cache,
createNodeId,
createResolvers,
store,
@sekmet
sekmet / FreeBSD_node_monit.md
Created June 22, 2019 07:10 — forked from fdelbos/FreeBSD_node_monit.md
FreeBSD 10 Nodejs setup with nginx, mongo and monit

FreeBSD 10 Nodejs setup with nginx, mongodb, redis and monit

This my receipe for installing a complete nodejs server on FreeBSD 10. The parameters used in this configuration are for a very small private server that I use for demo purpose only, so for a production server, you should somehow set the limits in pair with your ressources.

I use monit so I don't have to write rc scripts for node and it should take care of process lifecycle management for me. Alternatives exists such as supervisord or circus.

Installing mongodb

@sekmet
sekmet / loadimage.js
Created March 26, 2019 09:14 — forked from ahem/loadimage.js
Load and decode images with webworker
/* global createImageBitmap */
function loadImageWithImageTag(src) {
return new Promise((resolve, reject) => {
const img = new Image;
img.crossOrigin = '';
img.src = src;
img.onload = () => { resolve(img); };
img.onerror = () => { reject(img); };
});
@sekmet
sekmet / slugify.js
Created October 18, 2018 00:09 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@sekmet
sekmet / redirect-ingress.yml
Created September 18, 2018 12:01 — forked from sandcastle/redirect-ingress.yml
An example of a ingress redirect using kubernetes and nginx `configuration-snippet`
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: redirect-ingress
annotations:
ingress.kubernetes.io/configuration-snippet: |
if ($host ~ ^(.+)\.somedomain\.io$) {
return 301 https://$1.domain.io$request_uri;
}
spec:
@sekmet
sekmet / wp.sh
Last active August 22, 2018 16:18
Wordpress Install Bash v0.2.3
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress 4.9.x Install Script"
echo "============================================"
echo "Account User name: "
read -e accuser
echo "Database Host: "
read -e dbhost
echo "Database Name: "