Skip to content

Instantly share code, notes, and snippets.

View keineahnung2345's full-sized avatar
:octocat:
Focusing

keineahnung2345

:octocat:
Focusing
View GitHub Profile
@keineahnung2345
keineahnung2345 / global_wiki_redmine-5.0.5.patch
Created June 1, 2023 09:01
Global wiki feature for Redmine 5.0.5, adapted from draft-feature-1040-r20825.patch by Mizuki ISHIKAWA on https://www.redmine.org/issues/1040#note-66
---
app/controllers/attachments_controller.rb | 4 +-
app/controllers/wiki_controller.rb | 41 +++++++++++++------
app/helpers/application_helper.rb | 16 +++-----
app/helpers/wiki_helper.rb | 14 +++++--
app/models/wiki.rb | 21 ++++++++--
app/models/wiki_content.rb | 6 ++-
app/models/wiki_page.rb | 14 +++++--
app/views/wiki/_new_modal.html.erb | 2 +-
app/views/wiki/annotate.html.erb | 4 +-
@keineahnung2345
keineahnung2345 / cantor.py
Created October 1, 2021 14:30
Cantor pairing function for three integers(negative allowed)
# https://www.vertexfragment.com/ramblings/cantor-szudzik-pairing-functions/
# https://stackoverflow.com/questions/38965931/hash-function-for-3-integers
# https://math.stackexchange.com/questions/222709/inverting-the-cantor-pairing-function
def normalize(x):
# this function make cantor pairing function work for negative numbers
return 2*x if (x>=0) else (-2*x-1)
def normalize_inv(x):
return x//2 if (x % 2 == 0) else -(x+1)//2
@keineahnung2345
keineahnung2345 / CMakeLists.txt
Last active September 15, 2021 13:24
pcl mls upsampling test revised from https://github.com/PointCloudLibrary/pcl/issues/1958 for PCL 1.12
set (CMAKE_CXX_STANDARD 14)
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(MY_GRAND_PROJECT)
# specify the components required
#find_package(PCL 1.10 REQUIRED COMPONENTS common io)
# or use all available components
find_package(PCL 1.12 PATHS "$ENV{HOME}/Documents/pcl/build")
#find_package(PCL 1.10 REQUIRED)
include_directories("/usr/include/eigen3")
include_directories("$ENV{HOME}/Documents/pcl")
@keineahnung2345
keineahnung2345 / global_wiki_redmine-4.1.1.patch
Last active June 1, 2023 09:03
Global wiki feature for Redmine 4.1.1 and 4.1.2, adapted from draft-feature-1040-r20825.patch by Mizuki ISHIKAWA on https://www.redmine.org/issues/1040#note-66
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 4a88079..e7496fb 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -158,8 +158,10 @@ class AttachmentsController < ApplicationController
@attachment.destroy
end
+ container = @attachment.try(:container) || @container
respond_to do |format|
import zlib
import zipfile
from tqdm import tqdm
#https://stackoverflow.com/questions/47438424/python-zip-compress-multiple-files
def compress(path, file_names):
print("Containing directory:")
print(path)
print("File Paths:")
print(file_names)
@keineahnung2345
keineahnung2345 / jupyter_notebook_output_parser.py
Created November 28, 2020 03:11
A python script to parse commands and outputs from jupyter notebook
import json
nb_fname = "xxx.ipynb"
with open(nb_fname, "r", encoding="utf-8") as f:
nb = json.load(f)
cells = nb['cells']
print("There are", len(cells), "cells")
for cell in cells:
source = ''.join(cell['source'])
@keineahnung2345
keineahnung2345 / sourceforge_folder_downloader.py
Last active November 4, 2020 08:21
This script can download a folder(recursively) from sourceforge.net
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import wget #for downloading files
# convert url to normal string
from urllib.parse import unquote
import os
url_base = "https://sourceforge.net/"