Skip to content

Instantly share code, notes, and snippets.

@Junch
Junch / README-Highcharts-Webpack-Babel.md
Created January 4, 2018 07:25 — forked from jon-a-nygaard/README-Highcharts-Webpack-Babel.md
A Highcharts example in use with Webpack and Babel.

A Highcharts example in use with Webpack and Babel.

Install

  1. Download source files
  2. Run npm install to install all dependencies.
  3. Run npm run build to bundle app.js into bundle.js

Open application

  1. Open index.html in a browser.
@Junch
Junch / getrepo.js
Created July 3, 2018 09:42
Access the github repos with @octokit/rest.js
const octokit = require('@octokit/rest')();
octokit.authenticate({
type: 'token',
token: 'xxxxxx your token xxxxxxxx'
});
async function paginate (method) {
let response = await method({
owner: 'Junch',
@Junch
Junch / .clang-format
Created July 4, 2018 04:58
A clang format
---
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
BreakBeforeBraces: Allman
ColumnLimit: 0
NamespaceIndentation: All
最近使用pip3总会timeout,试了试下面的镜像站,速度却非常快
https://mirror.tuna.tsinghua.edu.cn/help/pypi/
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple
@Junch
Junch / reggetvalue.cpp
Last active July 13, 2018 05:36
Read the registry
#include <windows.h>
#include <iostream>
#pragma comment(lib, "advapi32.lib")
int main()
{
char value[255];
DWORD BufferSize = sizeof(value);
RegGetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "SystemRoot", RRF_RT_ANY, NULL, (PVOID)&value, &BufferSize);
@Junch
Junch / conversion.cpp
Created July 17, 2018 08:15 — forked from pezy/conversion.cpp
Encoding Conversion In C++
// Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring &wstr)
{
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo(size_needed, 0);
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
@Junch
Junch / mergejson.sh
Last active October 23, 2018 01:58
Script to generate the compile_commands.json
#!/bin/bash
# Refer to
# 1. http://blog.51cto.com/liveforlinux/689382
# 2. https://sarcasm.github.io/notes/dev/compilation-database.html
# 3. https://unix.stackexchange.com/questions/38172/switching-to-zsh-are-all-bash-scripts-compatible-with-zsh/38173
# 在scons文件中,添加 env.Append(CCFLAGS=['-MJ', '${TARGET}.json'])
find ./out/macosx-10.13-x86_64-rel/obj-static/src/ -name "*.o.json" | xargs sed -e '1s/^/[\'$'\n/' -e '$s/,$/\'$'\n]/' > compile_commands.json
@Junch
Junch / readme.md
Last active August 9, 2018 07:16
Run clang-tidy to modernize the code
find . -name *.cpp | xargs clang-tidy -header-filter='Spark*.*' -checks='-*,modernize-*,readability-*' -fix
@Junch
Junch / grep_ag_sed.sh
Last active April 12, 2021 07:47
Replace a string to another string in macOS
grep -rl --include=\*.java "boolean moreResults" . | xargs sed -i '' 's/boolean moreResults/boolean isFinishedSearching, boolean isMoreResults/g'
ag -l moreResults -G ".m" | xargs sed -i '' 's/moreResults:(BOOL)moreResults/isFinishedSearching:(BOOL)isFinishedSearching isMoreResults:(BOOL)isMoreResults/g'
noglob find . -type f -name SearchBoxPanel.* | xargs sed -i '' 's/bool moreResults/bool isFinishedSearching, bool isMoreResults/g'
find . -name AndroidABEquivalenceSearchQuery.cpp | xargs subl
@Junch
Junch / read_file.cpp
Created September 18, 2018 07:35
read a whole binary file to buffer
// https://bytefreaks.net/programming-2/c/cc-full-example-of-reading-a-whole-binary-file-to-buffer
struct binary_data_t
{
long size;
void *data;
binary_data_t() : size(0), data(nullptr) {}
~binary_data_t() { delete[] data; }
};