Skip to content

Instantly share code, notes, and snippets.

View gilbarbara's full-sized avatar
💥
Keep Buggering On

Gil Barbara gilbarbara

💥
Keep Buggering On
View GitHub Profile
@gilbarbara
gilbarbara / gitsubmodules.sh
Last active October 18, 2022 23:45
Install git submodules from a .gitmodules file
#!/bin/sh
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path
@gilbarbara
gilbarbara / chmodr.sh
Last active November 25, 2015 02:26
Change files and directories permissions recursively.
#!/bin/sh
#
# chmodr.sh
#
usage()
{
echo "Usage: $0 [-d DIRPERMS] [-f FILEPERMS] PATH"
exit 1
@gilbarbara
gilbarbara / APACHE: .htaccess pushstate
Created January 8, 2016 02:56 — forked from rayfranco/APACHE: .htaccess pushstate
.htaccess for HTML5 Pushstate support
<ifModule mod_rewrite.c>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html
</ifModule>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Socket</title>
<script src="https://radiovozes.com:8001/socket.io/socket.io.js"></script>
</head>
<body>
<h2 id="container"></h2>
@gilbarbara
gilbarbara / react-d3.jsx
Last active September 9, 2020 08:44
React + D3 example
import React from 'react';
import { autobind } from 'core-decorators';
import d3 from 'd3';
import moment from 'moment';
import classNames from 'classnames';
export default class EvolutionChart extends React.Component {
static propTypes = {
investment: React.PropTypes.object.isRequired,
size: React.PropTypes.array,
import React from 'react';
import { autobind } from 'core-decorators';
import { HOC } from 'formsy-react';
import { Input } from 'components/Input';
@autobind
export class InputValidate extends React.Component {
constructor(props) {
super(props);
@gilbarbara
gilbarbara / ReduxRouter.jsx
Last active November 28, 2019 18:01
react-router v4 with redux
import React from 'react';
import { Router } from 'react-router-dom';
import createBrowserHistory from 'history/createBrowserHistory';
const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
export const history = createBrowserHistory();
class ReduxRouter extends React.Component {
static propTypes = {
@gilbarbara
gilbarbara / ExportLayersToSVG.jsx
Created March 31, 2017 21:51
Export Illustrator layers to SVG files
var doc = app.activeDocument;
try {
if (app.documents.length > 0) {
var exportOpts = new ExportOptionsSVG();
if (doc.saved == false) {
doc.save();
}
@gilbarbara
gilbarbara / measurements.js
Last active May 7, 2017 17:48
Measurement data
const measurementsData = require('./measurements.json');
const newData = measurementsData.table.measurements.reduce((acc, val, idx) => {
acc.labels.push(val.name);
val.sizes.forEach((d, i) => {
let row = acc.data.find(r => r[0] === d.name);
if (!row) {
acc.data.push([d.name]);
@gilbarbara
gilbarbara / HtmlWrapper.js
Created December 25, 2017 15:11
Convert DOM node to React Element
@@ -0,0 +1,21 @@
import React from 'react';
import PropTypes from 'prop-types';
import ReactHtmlParser from 'react-html-parser';
export default class HtmlWrapper extends React.Component {
static propTypes = {
element: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object,