Skip to content

Instantly share code, notes, and snippets.

View cormacrelf's full-sized avatar
🦀

Cormac Relf cormacrelf

🦀
View GitHub Profile
@cormacrelf
cormacrelf / git index-exec.md
Last active November 10, 2022 18:30
A tool for operating on your git index, without stashing: git index-exec 'cargo fmt'

git-index-exec

A tool for operating on your git index, without stashing. It is common to want to commit only part of your working directory, but also be sure that each commit will compile if checked out, or has correctly formatted code. This tool checks out your current index to a temporary directory (stable for each unique git working dir PWD) and runs a shell snippet in it. It then takes any changes that command made, and applies them to the index.

*Hint: the 'index' is also known as the staging area. It's where the

<html><head>
<style>
.csl-bib-body {
line-height: 1.35;
display: grid;
/* left column as wide as it needs (but may shrink at small sizes);
right column fills the rest of the space. */
grid-template-columns: max-content 1fr;
}
.csl-block {
# must have ZEROTIER_API_KEY exported
accept='{"rulesSource": "accept;"}'
echo "$accept" | curl --silent -H "Authorization: Bearer $ZEROTIER_API_KEY" -d @- https://my.zerotier.com/api/network/ -o net.json
# get the id from the output using https://stedolan.github.io/jq/
ID=$(jq -r .id < net.json)
echo
@cormacrelf
cormacrelf / ProjectName.xml
Created December 12, 2016 11:35
RIDER-3009 reproduction in EAP14
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>a31a0acc-7bff-4a3b-bfb7-08e1921d6ade</ProjectGuid>
.

Keybase proof

I hereby claim:

  • I am cormacrelf on github.
  • I am cormacrelf (https://keybase.io/cormacrelf) on keybase.
  • I have a public key whose fingerprint is ACA4 7C39 CF00 604E B80B FAF9 4404 0B21 75A2 5B12

To claim this, I am signing this object:

@cormacrelf
cormacrelf / wordcount.vim
Created May 13, 2014 17:04
The best vim status line word count function. Grabs count from g<C-g> output, counts inside visual selections, and only re-runs itself when a buffer is modified, if it hasn't run yet, if we're in visual at all, or if we have changed modes since last run.
function! WordCount()
let currentmode = mode()
if !exists("g:lastmode_wc")
let g:lastmode_wc = currentmode
endif
" if we modify file, open a new buffer, be in visual ever, or switch modes
" since last run, we recompute.
if &modified || !exists("b:wordcount") || currentmode =~? '\c.*v' || currentmode != g:lastmode_wc
let g:lastmode_wc = currentmode
let l:old_position = getpos('.')
java.io.StreamCorruptedException: invalid stream header: 5B424033
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
at com.stripe.ctf.instantcodesearch.AbstractSearchServer.decodeMapResponse(AbstractSearchServer.scala:90)
at com.stripe.ctf.instantcodesearch.SearchMasterServer$$anonfun$mergeResponses$1.apply(SearchMasterServer.scala:93)
at com.stripe.ctf.instantcodesearch.SearchMasterServer$$anonfun$mergeResponses$1.apply(SearchMasterServer.scala:93)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
def encodeMapResponse(results: List[Match]): HttpResponse = {
val response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
val stream = new ByteArrayOutputStream(1024)
val w = new ObjectOutputStream(stream)
try {
w.writeObject(results)
} catch {
case e:IOException => Console.err.println(id + ": " + e)
}
w.close
// format: [dest: msg, dest2: msg2]
acc := make(map[string][]string, len(args.recipients))
for _, r := range args.recipients {
remote := dealers[r]
remote.SendMessage(args.msg)
}
for _, r := range args.recipients {
remote := dealers[r]
msg, err := remote.RecvMessage(0)
if err == nil {