Skip to content

Instantly share code, notes, and snippets.

View ioncodes's full-sized avatar
😴
Playing with memory regions...

Layle | Luca ioncodes

😴
Playing with memory regions...
View GitHub Profile
@ioncodes
ioncodes / FileAssociation.cs
Last active October 16, 2017 19:22
Adds file extension association to windows.
static void CreateFileAssociations()
{
/***********************************/
/**** Key1: Create ".cy" entry ****/
/***********************************/
Microsoft.Win32.RegistryKey key1 = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", true);
key1.CreateSubKey("Classes");
key1 = key1.OpenSubKey("Classes", true);
@ioncodes
ioncodes / GetEditorText.cs
Created July 28, 2016 09:39
Shows how to get the text from the active document via DTE
private DTE _dte;
private NAME(Package package)
{
// ...
_dte = (DTE) ServiceProvider.GetService(typeof(DTE));
// ...
}
private static string GetDocumentText(Document document)
@ioncodes
ioncodes / fader.hpp
Created September 21, 2016 15:26
Header to set the transparency of your console.
#include <Windows.h>
inline BOOL WindowTransparency(HWND hwnd, BYTE bAlpha)
{
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, RGB(255, 255, 255), bAlpha, 2);
return true;
}
inline VOID SetTransparency(int transparency)
@ioncodes
ioncodes / .gitlab-ci.yml
Last active October 13, 2016 10:08
Batch to compile Qt projects via MinGW automatically. Also added the YAML file.
stages:
- build
job:
stage: build
script:
- echo "Release build..."
- C:\Qt\5.7\mingw53_32\bin\qtenv2_gitlab.bat
tags:
except:
@ioncodes
ioncodes / morsecodes.java
Created January 24, 2017 08:41
HashMap<String,String> of morse codes which I need for school
HashMap<String,String> morseCodes = new HashMap<String,String>() {{
put("A", ".-");
put("B", "-...");
put("C", "-.-.");
put("D", "-..");
put("E", ".");
put("F", "..-.");
put("G", "--.");
put("H", "....");
put("I", "..");
@ioncodes
ioncodes / ExecuteMethod.cs
Created January 27, 2017 08:37
Loads an assembly and executes the method with the specified arguments. Has support for BindingFlags.
public static object ExecuteMethod(string asm, string stype, string smethod, BindingFlags flags, object[] arguments)
{
Assembly assembly = Assembly.LoadFile(asm);
Type type = assembly.GetType(stype);
MethodInfo method = type.GetMethod(smethod, flags);
return method.Invoke(null, arguments);
// Usage: (int)ExecuteMethod("test.dll", "Namespace.Class", "CalculateTwoInts", BindingFlags.Static | BindingFlags.Public, new object[] {1,2});
}
@ioncodes
ioncodes / References.cs
Created February 5, 2017 13:37
Get's the calls in a method and adds them to a list. Uses dnlib.
private static List<string[]> GetReferences(ModuleDef module)
{
var typeSet = new HashSet<string>();
foreach (var type in module.Types)
{
typeSet.Add(type.Name);
}
var refs = (from type in module.Types from method in type.Methods where method.HasBody from instruction in method.Body.Instructions where instruction.OpCode == OpCodes.Call from set in typeSet where type.Name != set where instruction.Operand.ToString().Contains(set) select new string[] {type.Name, set}).ToList();
return refs.GroupBy(strArr => string.Join("|", strArr))
.Select(g => g.First())
@ioncodes
ioncodes / glyphicon-scraper.js
Last active February 15, 2017 18:06
Scrapes all the glyphicons classnames from http://glyphicons.bootstrapcheatsheets.com/
var spans = document.getElementsByTagName('SPAN');
var names = [];
for(var i = 0; i < spans.length; i++) {
if(spans[i].className.indexOf('glyphicon') !== -1) {
names.push(spans[i].className.split(' ').pop());
}
}
var svg = document.getElementsByTagName('LI');
var names = [];
for(var i = 0; i < svg.length; i++) {
names.push(svg[i].getAttribute('data-name'));
}
var devIcons = document.getElementsByClassName('devicons');
var icons = [];
for(var i = 0; i < devIcons.length; i++) {
if(i%5 === 0) {
icons.push(devIcons[i].className.split(' ').pop());
}
}