Skip to content

Instantly share code, notes, and snippets.

Fix internet with USB cable

$ sudo ifconfig -a

find the your interface

$ sudo ifconfig <interface> up

edit interfaces

class Array:
def __init__(self, shape, *values):
"""
Make sure that you check that your array actually is an array, which means it is homogeneous (one data type).
Args:
shape (tuple): shape of the array as a tuple. A 1D array with n elements will have shape = (n,).
*values: The values in the array. These should all be the same data type. Either numeric or boolean.
Raises:
ValueError: If the values are not all of the same type.
ValueError: If the number of values does not fit with the shape.
#!/bin/bash
FILE=$LOGFILE
WORKING_DIR=$(pwd)
MESSAGE="This program works as follows: track [start | <jobname>][stop][status]
track start <jobname>, will start track logging in the specified log file.
track status, reads from the last line of the log file and checks if there is a logged job.
track stop, stop the job
"
if [ -z "$FILE" ]; # check if there is an environment - if not export default one
const express = require("express");
const app = express();
const port = process.env.PORT || 8080;
const router = express.Router();
const fetch = require("node-fetch");
const cors = require("cors");
require("dotenv").config();
app.use(cors());
app.use(express.json());
const request = require('request');
const Url = "https://classic.warcraftlogs.com/rankings/guild-rankings-for-zone/479751/dps/1000/0/3/40/1/Warlock/Any/rankings/historical/0/best/0/0?dpstype=rdps"
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const options = {
url: Url,
headers: {
'Referer': 'https://classic.warcraftlogs.com/guild/rankings/479751/latest/?fbclid=IwAR3dpojQF9qpngXFTRYfxJ8LVUzEGPQgfpfwlvVHvloRseVFo4Puf_frP7I',
}
@181221
181221 / use reducer v2.js
Created March 21, 2019 16:49
use reducer v2 form validator
import React, { Component, useState, useReducer } from "react";
import logo from "./logo.svg";
import "./App.css";
const reducer = (state, { el, type }) => {
switch (type) {
case "name": {
if (el.value === "") {
return {
...state,
@181221
181221 / form validator useReducer.js
Last active March 21, 2019 16:48
form validator useReducer
import React, { Component, useState, useReducer } from "react";
import logo from "./logo.svg";
import "./App.css";
const useFormInput = initialValue => {
const [value, setValue] = useState(initialValue);
const handleChange = ({ target: { value } }) => {
setValue(value);
};
import React, { useContext, useState, createContext } from 'react';
const ExpandContext = createContext(null);
const ListHeader = () => {
const { open, setOpen } = useContext(ExpandContext);
return (
<div>
<button onClick={() => setOpen(!open)}>click to expand</button>
</div>
@181221
181221 / app.js
Created March 1, 2019 15:04
The oldway - example for elisabeth.
import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";
class App extends Component {
constructor() {
super();
this.state = {
data: undefined,
url: "https://demo2480495.mockable.io/events"
import React, { useState, useEffect } from 'react';
function SubEvent(props){
const {subevent: {location, name, start, stop}} = props
let tidStart = new Date(start).toLocaleTimeString(navigator.language, {hour: '2-digit', minute:'2-digit'})
let tidStop = new Date(stop).toLocaleTimeString(navigator.language, {hour: '2-digit', minute:'2-digit'})
return (
<div>
<h1>{location}</h1>
<div>{name}</div>