Skip to content

Instantly share code, notes, and snippets.

@andrepcg
andrepcg / dns.md
Created Jun 12, 2019
Usar Pi-Hole em todos os devices da rede (excepto box IPTV da vodafone)
View dns.md
  1. Activar servidor DHCP no Pi-Hole
  2. Criar ficheiro /etc/dnsmasq.d/03-vodafone.conf
  3. Adicionar a seguinte configuração ao ficheiro
dhcp-host=<MAC ADDRESS DA TV BOX>,set:vodafone
dhcp-option=tag:vodafone,option:dns-server,<IP DO ROUTER DA VODAFONE>

Agora a Box continua a funcionar porque usa o DNS que o router da Vodafone lhe dá e todos os restantes dispositivos na rede utilizam o DNS anunciado pelo servidor DHCP que é o do Pi-Hole

View GreetingsHooks.js
import React, { useState, useContext, useEffect } from "react";
import { Card, Row, Input, Text } from "./components";
import ThemeContext from "./ThemeContext";
function Greeting(props) {
let [name, setName] = useState("Harry");
let [surname, setSurname] = useState("Potter");
let theme = useContext(ThemeContext);
useEffect(() => {
View GreetingsClass.js
import * as React from "react";
import { Card, Row, Input, Text } from "./components";
import ThemeContext from "./ThemeContext";
class Greeting extends React.Component {
constructor() {
super(...arguments);
this.state = {
name: "Harry",
sureName: "Potter",
View useCounter.js
import React, { useState } from "react";
const useCounter = (initialValue) => {
const [count, setCount] = useState(initialValue);
const increment = () => setCount(count + 1);
const decrement = () => setCount(count - 1);
return { count, increment, decrement };
};
function Counter() {
View useState.counter..js
import React, { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
{count}
</button>
);
}
View react.memo.js
const Product = React.memo((props) => {
const { name, price } = props;
return (
<div className="product-info">
<span>{name}</span>
<span>{price}</span>
</div>
);
});
View keybase.md

Keybase proof

I hereby claim:

  • I am andrepcg on github.
  • I am andrepcg (https://keybase.io/andrepcg) on keybase.
  • I have a public key whose fingerprint is BA4A F148 669B D4D3 B8E0 B1EA 2B73 D827 47E0 DBE4

To claim this, I am signing this object:

@andrepcg
andrepcg / shipitfile.js
Created Jan 20, 2018 — forked from jbraithwaite/shipitfile.js
Shipit deploy with Slack integration
View shipitfile.js
var pack = require('./package.json');
var request = require('request');
var name = pack.name;
module.exports = function (shipit) {
require('shipit-deploy')(shipit);
var deployTo = '/var/www/FOLDER_TO_DEPLOY_TO';
var deployToCurrent = deployTo + '/current';
var slackWebhookURL = 'SLACK_HOOK_URL';
View dlib and face_recognition on raspberry pi.md

Install dlib and face_recognition on a Raspberry Pi

Instructions tested with a Raspberry Pi 2 with an 8GB memory card. Probably also works fine on a Raspberry Pi 3.

Steps

Download the latest Raspbian Jessie Light image. Earlier versions of Raspbian won't work.

Write it to a memory card using Etcher, put the memory card in the RPi and boot it up.

View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
You can’t perform that action at this time.