Skip to content

Instantly share code, notes, and snippets.

@rylev
rylev / rust-in-large-organizations-notes.md
Last active February 2, 2023 10:08
Rust in Large Organizations Notes

Rust in Large Organizations

Initially taken by Niko Matsakis and lightly edited by Ryan Levick

Agenda

  • Introductions
  • Cargo inside large build systems
  • FFI
  • Foundations and financial support
@hengyunabc
hengyunabc / ClassLoaderUtils.java
Created October 12, 2017 12:02
Get SystemClassLoader/ClassLoader urls in java9
/**
*
* @author hengyunabc 2017-10-12
*
*/
public class ClassLoaderUtils {
@SuppressWarnings({ "restriction", "unchecked" })
public static URL[] getUrls(ClassLoader classLoader) {
if (classLoader instanceof URLClassLoader) {
return ((URLClassLoader) classLoader).getURLs();
@hmldd
hmldd / scroll.py
Last active October 6, 2023 14:59
Example of Elasticsearch scrolling using Python client
# coding:utf-8
from elasticsearch import Elasticsearch
import json
# Define config
host = "127.0.0.1"
port = 9200
timeout = 1000
index = "index"
@lpsandaruwan
lpsandaruwan / JVMCPUUsage.java
Last active March 13, 2019 10:16
Calculate JVM CPU Usage Using MXBeans
/* JVMCPUUsage
*
* Calculate JVM CPU usage on older than JDK version 7 using MXBeans.
*
* First initiate MBeanServerConnection using `openMBeanServerConnection` method. Then
* create proxy connections to MXBeans using `getMXBeanProxyConnections` and after that
* poll `getJvmCpuUsage` method periodically.
*
* JVMCPUUsage is a free Java class:
* you can redistribute it and/or modify it under the terms of the GNU General Public License
@apangin
apangin / Bytecodes.java
Created January 31, 2016 19:16
Using JVMTI to obtain bytecodes of a Java method
import java.lang.reflect.Method;
import java.util.Arrays;
public class Bytecodes {
static {
System.loadLibrary("bytecodes");
}
private static native byte[] getBytecodes(Method method);
@ocornut
ocornut / (Archived) imgui_memory_editor.h
Last active January 1, 2024 04:27
Mini memory editor for dear imgui (to embed in your game/tools)
// Mini memory editor for Dear ImGui (to embed in your game/tools)
// Animated GIF: https://twitter.com/ocornut/status/894242704317530112
// THE MEMORY EDITOR CODE HAS MOVED TO GIT:
// https://github.com/ocornut/imgui_club/tree/master/imgui_memory_editor
// Click "Revisions" on the Gist to see old version.
@nightire
nightire / 解决 Git 在 windows 下中文乱码的问题.md
Last active April 24, 2024 16:19
解决 Git 在 windows 下中文乱码的问题

解决 Git 在 windows 下中文乱码的问题

原因

中文乱码的根源在于 windows 基于一些历史原因无法全面支持 utf-8 编码格式,并且也无法通过有效手段令其全面支持。

解决方案

  1. 安装
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@taxilian
taxilian / BitBlitter.cpp
Last active January 4, 2020 01:53
Example mac CoreGraphics draw function for FireBreath
// Platform independent
#include "BitBlitter.h"
#include "precompiled_headers.h" // Anything before this is PCH on windows
bool BitBlitter::onWindowRefresh( FB::RefreshEvent *evt, FB::PluginWindow *win )
{
boost::mutex::scoped_lock _l(preview_mutex);
@taxilian
taxilian / ImageDraw.cpp
Created July 6, 2011 21:21
Example windows image draw function for FireBreath
void PluginObject::drawImage(FB::PluginWindow *wnd, FB::PluginEvent* evt, unsigned char *img, int width, int height) {
HDC hdc=NULL;
BITMAPINFO bitmapInfo;
bitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bitmapInfo.bmiHeader.biBitCount=32;
bitmapInfo.bmiHeader.biCompression=BI_RGB;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biSizeImage = width*height*4;
bitmapInfo.bmiHeader.biWidth = width;