Skip to content

Instantly share code, notes, and snippets.

@caverna
caverna / ShaderCompiler.cs
Last active August 9, 2023 09:15
OpenGL shader compiler from embedded resources
using System.Text;
using OpenTK.Graphics.OpenGL4;
public static class ShaderCompiler
{
public static int GetShaderHandle(string vertexName, string fragmentName)
{
var shaderHandle = GL.CreateProgram();
var vertexShader = CompileShader(vertexName, ShaderType.VertexShader);
var fragmentShader = CompileShader(fragmentName, ShaderType.FragmentShader);
@caverna
caverna / script.sql
Created April 26, 2023 07:09
SQL user without login
/*
https://stackoverflow.com/questions/25310954/why-change-user-type-to-sql-user-with-login-is-disabled-in-ssms
*/
USE DatabaseName;
ALTER USER UserName WITH LOGIN = LoginName;
@caverna
caverna / reset-mysql-8-root-password-windows.md
Last active October 18, 2022 07:47 — forked from pishangujeniya/reset-mysql-8-root-password-windows.md
Reset MySQL 8.0 root Password in Windows

Reset MySQL 8.0 root Password in Windows

  1. Stop the MySQL 8.0service from services
  2. Go to path C:\Program Files\MySQL\MySQL Server 8.0\bin and open cmd
  3. Run mysqld --console --skip-grant-tables --shared-memory --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini"
  4. Open new cmd in the same path
  5. Run following commands
  6. mysql -u root
  7. select authentication_string,host from mysql.user where user='root';
  8. UPDATE mysql.user SET authentication_string='' WHERE user='root';
@caverna
caverna / startup.gcode
Last active February 26, 2022 10:23
Startup gcode for MY 3d printer (Cura)
; Settings for WarmUp before AutoLeveling
M140 S45 ; warm up bed
M104 S150 T0 ; warm up hotend
M280 P0 S160 ; BLTouch alarm release
G28 ; Home all axes
G0 X0 Y20 F5000 ; Move to start probe position
M190 S45 ; wait for bed warm up
M109 S150 T0 ; wait for hotend warm up
G29 ; Auto Leveling
@caverna
caverna / fGetPublishDate_XMLNode.vb
Created February 3, 2022 09:30
Read/Write "PublishDate" Word quick text
' extracted from http://www.vbaexpress.com/forum/showthread.php?43269-Writing-to-Word-quot-Publish-Date-quot-Document-Property&s=e98d9dd27d2cc1736a3ab375afb6d90b&p=274084&viewfull=1#post274084
Public Sub DemoPublishDate()
'the current value (notice the standard format is "yyyy-mm-ddT00:00:00"
'when a content control has last set the value
MsgBox fGetPublishDate_XMLNode
'update the value and display that we updated it
MsgBox fGetPublishDate_XMLNode(Format(Now, "m/d/yyyy"))
End Sub
@caverna
caverna / Global.asax.cs
Created November 2, 2020 14:29
JSON setup for ASP.NET MVC
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
RouteConfig.RegisterRoutes(RouteTable.Routes);
SetupJsonSerialize(); // <---
@caverna
caverna / IMessageFilter.cs
Created September 22, 2020 07:51
Handling COM calls rejected by AutoCAD from an external .NET application
using System;
using System.Runtime.InteropServices;
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("00000016-0000-0000-C000-000000000046")]
public interface IMessageFilter
{
[PreserveSig] int HandleInComingCall(int dwCallType, IntPtr hTaskCaller, int dwTickCount, IntPtr lpInterfaceInfo);
[PreserveSig] int RetryRejectedCall(IntPtr hTaskCallee, int dwTickCount, int dwRejectType);
@caverna
caverna / PictureConverter.cs
Created July 29, 2020 10:38
System.Drawing.Image to stdold.IPictureDis (used by Inventor toolbar)
using System;
using System.Runtime.InteropServices;
using stdole;
public static class PictureConverter
{
// https://adndevblog.typepad.com/manufacturing/2012/06/how-to-convert-iconbitmap-to-ipicturedisp-without-visualbasiccompatibilityvb6supporticontoipicture.html
private static Guid iPictureDispGuid = typeof(IPictureDisp).GUID;
@caverna
caverna / dummy.xml
Created March 12, 2020 08:14
Windchill LDAP 2 DisplayName
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>
<%@page language="java" access="http|internal"%>
<%@page import="com.infoengine.object.IeDatum"%>
<%@page import="wt.org.OrganizationServicesMgr"%>
<%@page import="wt.org.WTUser"%>
<%
/* Windchill LDAP 2 DisplayName */
Enumeration elements = getGroup("Output").getElements();
while (elements.hasMoreElements()) {
@caverna
caverna / BundleExtensions.cs
Last active July 24, 2019 10:36
Append "Last Modified Token" and "CSS Rewrite URL" for Bundle config
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Hosting;
using System.Web.Optimization;
public static class BundleExtensions
{
public static Bundle WithLastModifiedToken(this Bundle bundle)
{