Skip to content

Instantly share code, notes, and snippets.

const getContiguousIds = ({
contiguousIds = [],
node,
nodes,
}) => (
node
.adjacentIds
.reduce(
(
contiguousIds,
@dsc712
dsc712 / VideoDetail.js
Created February 15, 2019 12:01
Video List Detail
import React, { Component } from 'react';
import { Icon } from "antd";
class VideoDetail extends Component {
state = {
video: null
};
componentDidUpdate(prevProps) {
if( this.props.video && ( prevProps.video !== this.props.video) ) {
import sys
from tweepy import OAuthHandler
from tweepy import API
from tweepy import Stream
from tweepy.streaming import StreamListener
# Replace the "None"s by your own credentials
ACCESS_TOKEN = None
ACCESS_TOKEN_SECRET = None
@alexeyzimarev
alexeyzimarev / JsonNetRestSharp.cs
Created December 30, 2018 21:08
Using Newtonsoft.Json with RestSharp v106.6
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Serialization;
namespace JsonNetRestSharp
{
class Program
{
static void Main(string[] args)
{
import * as cocoSsd from "@tensorflow-models/coco-ssd";
const image = document.getElementById("image")
cocoSsd.load()
.then(model => model.detect(image))
.then(predictions => console.log(predictions))
@nabrown
nabrown / FigureStandardRF.js
Created July 27, 2018 22:31
Standard component using a render function
export default {
props: {
src: {
required: true,
type: String
},
type: {
required: true,
type: String
@rhythnic
rhythnic / vuex-reusable-functions.js
Last active October 21, 2022 07:41
Reusable Vuex Functions
// *******************************************************************
// ATTENTION
// This gist is now an npm module
// The API of some functions is altered slightly.
// All future work will happen in the repo.
//
// https://gitlab.com/rhythnic/vuex-intern
// *******************************************************************
// *******************************************************************
@bagder
bagder / trrprefs.md
Last active December 27, 2022 05:17
This once held TRR prefs. Now it has moved.

NOTE

This content has moved.

Please go to bagder/TRRprefs for the current incarnation of the docs, and please help us out polish and maintain this documentation!

@chlab
chlab / README.md
Last active April 28, 2021 09:48
vue webpack boilerplate: how to add env-specific build targets

When using the vue-webpack-boilerplate, you will have only a production build by default (besides dev and test setups). My team often has at least another environment we call "staging" where the client can test new features before we move them to production. Oftentimes, these environments will have env-specific config values, like a different API URL.

With the changes outlined below, you can create a separate config per environment. This assumes you've created a Vue.js project with vue-webpack-boilerplate.

  1. Apply the changes to the corresponding files in your project as outlined below
  2. Now, when you run npm run build staging it will build your project with the config values specific to your staging environment. You can easily add any number of other environments and build them the same way. npm run build or npm run build production will still build your production environment.
@headius
headius / meltdown_in_a_nutshell.md
Last active July 27, 2018 13:43
How Meltdown Works

Algorithm

  1. A secret byte you want to read is stored at inaccessible memory location priv_mem.
  2. The sender triggers an access exception by attempting to read priv_mem.
  3. Due to CPU optimization (out-of-order execution), the load of secret from priv_mem and the use of its value in (4) and (5) below may execute before the exception is triggered.
  4. Calculate an offset into a known array probe by multiplying secret by the width of a cache line (or whatever block size the CPU typically fetches, like a 4096-byte page). This guarantees each of those 256 possible offsets will cache separately.
  5. Load probe[offset], which causes the CPU to cache exactly one chunk of of our array, populating one cache line.
  6. The exception finally triggers, clearing the modified registers...but cached data is not excised.
  7. Iterate over all 256 offsets into probe to find out which one loads fast. You've determined the value of secret.