Skip to content

Instantly share code, notes, and snippets.

View csharpforevermore's full-sized avatar
💭
Developing

Randle csharpforevermore

💭
Developing
View GitHub Profile

Frontend Development

Looking for something else? Take a look at the awesome collection of other awesome lists.

@csharpforevermore
csharpforevermore / Rename-Files.ps1
Created February 27, 2020 18:28 — forked from auberginehill/Rename-Files.ps1
A Windows PowerShell script for renaming files.
<#
Rename-Files.ps1
#>
# Find all wmv-files with a string "oldstring" and replace "oldstring" with "newstring" in the filename
Get-ChildItem *.wmv -Filter "*oldstring*" | ForEach { Rename-Item $_ -NewName $_.Name.Replace("oldstring","newstring") }
# Change the file extension of all .jpeg files to .jpg
@csharpforevermore
csharpforevermore / umbraco 7 db cleanup.sql
Last active December 15, 2021 14:02 — forked from dampee/umbraco db cleanup.sql
Umbraco Database cleanup. After pulling in an umbraco database from production, you don't need all history or log.
-- Umbraco Clear Old Document Versions To Decrease Database Size And Improve Performance
-- http://borism.net/2008/12/16/fixing-a-large-cmspropertydata-table-in-umbraco/
DECLARE @createdDate Datetime = DATEADD(m, -1, getdate())
-- dump logs
-- TRUNCATE TABLE umbracolog -- faster if log table is very big and you don't need anything
DELETE FROM umbracolog WHERE Datestamp < @createdDate
-- clean up old versions
DELETE FROM cmsPropertyData WHERE
SELECT STRAIGHT_JOIN categories.id, categories.title, categories.game_count, categories.display_order FROM `categories` INNER JOIN `category_namespaces` ON `category_namespaces`.`category_id` = `categories`.`id` WHERE `categories`.`type` IN ('ClickJogos::GameCategory') AND `categories`.`published` = 1 AND (category_namespaces.namespace = 'jgo') ORDER BY
CASE
WHEN categories.id LIKE '447%' THEN 1
WHEN categories.id LIKE '448%' THEN 2
ELSE 3
END, categories.game_count DESC;
@csharpforevermore
csharpforevermore / pdconcat.py
Created June 16, 2018 15:07 — forked from phobson/pdconcat.py
funky pandas concat
import numpy
import pandas
numpy.random.seed(0)
index1 = pandas.MultiIndex.from_product(
[['A'], ['b'], ['one', 'two']],
names=['City', 'Street', 'House']
)
index2 = pandas.MultiIndex.from_product(
@csharpforevermore
csharpforevermore / join.py
Created June 16, 2018 15:03 — forked from finswimmer/join.py
Join multiple pandas dataframes
import glob
import sys
import pandas
def read_filenames(names):
for arg in names:
if "*" in arg:
for file in glob.glob(arg):
yield file
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
if (fuImage.HasFile)
{
PostedMediaFile postedMediaFile = new PostedMediaFile
{
ContentLength = fuImage.PostedFile.ContentLength,
ContentType = fuImage.PostedFile.ContentType,
FileName = fuImage.PostedFile.FileName,
InputStream = fuImage.PostedFile.InputStream
};
Media media = MediaFactory.GetMediaFactory(-1, postedMediaFile, new umbraco.BusinessLogic.User(0)).HandleMedia(-1, postedMediaFile, new umbraco.BusinessLogic.User(0), true);
@csharpforevermore
csharpforevermore / FileUploadAspNet.cs
Last active December 30, 2015 04:09 — forked from Benrnz/FileUploadAspNet.cs
Uploads a file to the server and save it to disk. (INCOMPLETE)
public static bool UploadToServer(string pathToFile)
{
bool failure = false;
if (!FileUpload1.FileName.ToLowerInvariant().EndsWith(".xml")) {
failure = true;
}
StreamReader reader = new StreamReader(FileUpload1.FileContent);
string xmlContent = reader.ReadToEnd();
if (!xmlContent.TrimStart().StartsWith("<?xml")) {