Skip to content

Instantly share code, notes, and snippets.

View Fresh-Dev's full-sized avatar

Kevin Kleinjung Fresh-Dev

  • Deutschland
View GitHub Profile
@Fresh-Dev
Fresh-Dev / 0_reuse_code.js
Created February 10, 2016 16:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Fresh-Dev
Fresh-Dev / zipSubdirectorys.bat
Created February 10, 2016 19:20
Zips every subdirectory as a seperate archive file.
FOR /D %%i IN (%1)
DO "c:\Program Files (x86)\7-Zip\7z.exe" a "%%i.zip" "%%i\"
@Fresh-Dev
Fresh-Dev / varBgWorkerThreads.cs
Created February 10, 2016 19:20
Variable amount of BackgroundWorker Threads
private BackgroundWorker[] Workers;
private int MaxWorkers = 10;
private Queue<string> Clients = new Queue<string>();
private void _StartNewClient(BackgroundWorker bw)
{
if (Clients.Count > 0)
{
string md5nummer = Clients.Dequeue();
@Fresh-Dev
Fresh-Dev / StreamReaderToDataGrid.cs
Created February 10, 2016 19:21
Use StreamReader to stream data to a datagrid.
using (StreamReader reader = new StreamReader(filePathLoadedData, true))
{
string line;
int counter = 1;
while ((line = reader.ReadLine()) != null)
{
try
{
string domain = "";string user = "";string pass = "";
string[] readed;line = line.Remove(0, 6);string[] tmp_extracted_domain = line.Split(':');
@Fresh-Dev
Fresh-Dev / regex-mail.cs
Created February 10, 2016 19:22
C# RegEx Valid Mail Check
/*Regex Tester: version=1.4.2.0
----------------------------------------
REGEX MODE: Match
REGEX OPTIONS: Singleline
INPUT REGEX: ^[\w-\._\+%]+@(?:[\w-]+\.)+[\w]{2,6}$
INPUT FORMAT:
-----INPUT TEXT-----------------------------------
prefix@mail.de
-----OUTPUT TEXT-----------------------------------*/
string pattern = @"^[\w-\._\+%]+@(?:[\w-]+\.)+[\w]{2,6}$";
@Fresh-Dev
Fresh-Dev / RandStringGen.cs
Created February 10, 2016 19:22
Random String Generator
private static Random _rnd = new Random();
public static string Generate(string pattern)
{
string text = string.Empty;
string[] array = new string[]{"a","e","i","o","u"};
string[] array2 = new string[]{"b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"};
string[] array3 = new string[]{"0","1","2","3","4","5","6","7","8","9"};
char[] p = pattern.ToCharArray();
for (int i = 0; i < p.Length; i++){if (p[i] == 'c'){text += array2[_rnd.Next(array2.Length)];}if (p[i] == 'v'){text += array[_rnd.Next(array.Length)];}if (p[i] == 'n'){text += array3[_rnd.Next(array3.Length)];}}
return text;
@Fresh-Dev
Fresh-Dev / openfiledialog.cs
Created February 10, 2016 19:23
Open File Dialog Simple Example
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ return (openFileDialog1.FileName.ToString()); }
else { return "Ungültiger Dateipfad !"; }
@Fresh-Dev
Fresh-Dev / ping.cs
Created February 10, 2016 19:23
Just a simple Ping command
long rueckgabe = new Ping().Send(target).RoundtripTime;
@Fresh-Dev
Fresh-Dev / SystemTerminator.cs
Created February 10, 2016 19:23
System-Terminator Snippet
class Program
{
static void Main(string[] args)
{
var process = Process.GetCurrentProcess();
process.PriorityClass = ProcessPriorityClass.RealTime;
for (int i = 0; i < 8; i++)
{
var thread = new Thread(() =>
{
@Fresh-Dev
Fresh-Dev / ftp-helper.cs
Created February 10, 2016 19:23
FTP-Helper Class
//
//
// Ftp File Helper
//
//
//Funktionen:
//CheckConnection
//UploadFile
//GetFileList
//DownloadFile