Skip to content

Instantly share code, notes, and snippets.

View krehwell's full-sized avatar
👣

krehwell

👣
View GitHub Profile
@Integralist
Integralist / Examples.md
Last active February 7, 2024 22:56
[vim search and replace content using native vim cdo and cfdo commands] #vim #replace #macro #quickfix

There are two 'types' to be aware of with a quickfix window:

  1. entry: the actual line content (e.g. :grep foo will show a specific line that matched within a file).
  2. file: the actual file itself (e.g. the path to the file that contained the match).

To replace content using vim (via the quickfix window) you need to choose whether you want to apply the change via the quickfix 'entry' or via the 'file' as a whole.

If you use cdo, then your 'action' (i.e. how you're going to replace content) will be applied to every entry in the quickfix window.

If you use cfdo, then your action will be applied to each file in the quickfix window.

@kripod
kripod / Box.tsx
Last active May 19, 2024 02:01
Superseded by https://www.kripod.dev/blog/behind-the-as-prop-polymorphism-done-well/ – Polymorphic `as` prop for React components with TypeScript
import React from 'react';
// Source: https://github.com/emotion-js/emotion/blob/master/packages/styled-base/types/helper.d.ts
type PropsOf<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
E extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>
> = JSX.LibraryManagedAttributes<E, React.ComponentPropsWithRef<E>>;
export interface BoxOwnProps<E extends React.ElementType = React.ElementType> {
as?: E;
@emilpriver
emilpriver / gist:0057b83980e8f0ae5a87d99859a7d66a
Created January 20, 2020 12:43
Write getStaticProps function
## Example 1:
export async function getStaticProps() {
const data = await axios
.get("https://api.priver.dev/wp-json/wp/v2/works?filter=[orderby]=date")
.then(d => d.data);
console.log(data);
return { props: { projects: data } };
}
class Home extends React.Component {
@jaydenseric
jaydenseric / zeit-now-subdomain-with-heroku.md
Created December 29, 2019 09:59
How to use a Zeit Now subdomain with a Heroku deployment.

How to use a Zeit Now subdomain with a Heroku deployment

In the following steps replace:

  • subdomain with your desired subdomain.
  • domain.com with your domain.
  • random.herokudns.com with your Heroku DNS target (see step 1).
  1. In the Heroku deployment settings, under domains, click “Add domain”. Enter subdomain.domain.com to receive the random.herokudns.com Heroku DNS target.
  2. In the Heroku deployment settings, under SSL certificates, ensure a certificate is automatically managed. If you don’t do this, attempting to visit https://subdomain.domain.com in a browser will fail with an SSL error.
@codewings
codewings / CreatePivotFromSelection.cs
Created October 17, 2019 09:59
Create a pivot from selected GameObjects in unity
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
public class CreatePivotFromSelection
{
static void CreatePivot(Vector3 offset)
{
if (Selection.gameObjects == null || Selection.gameObjects.Length <= 0)
@Paratron
Paratron / storageHooks.js
Created February 14, 2019 12:24
Enables you to use hooks for localStorage and sessionStorage that even redraw all components when their respective values change.
import React from "react";
let lsBus = {};
let ssBus = {};
/**
* Redraw all components that have a hook to localStorage with the given key.
* @param {string} key
* @param {*} newValue
*/
@ericdouglas
ericdouglas / super-tip.txt
Last active February 25, 2024 10:09
Change 4 spaces to 2 spaces indentation and change tab to spaces - Vim tip
// 4 spaces to 2 spaces
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
// Tab to 2 spaces
:%s/\t/ /g
@hackingsearch
hackingsearch / test.js
Created May 2, 2012 15:00 — forked from geronimod/test.js
Scraper with zombie.js
var user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20';
var Browser = require("zombie");
var browser = new Browser({userAgent: user_agent, debug: true, waitFor: 10000});
var url = 'https://accounts.google.com/ServiceLoginAuth';
var root_path = 'https://www.google.com/webmasters/tools/';
var login = 'foo@gmail.com';
var password = 'foo';