Skip to content

Instantly share code, notes, and snippets.

View NaserKhoshfetrat's full-sized avatar

Naser Khoshfetrat NaserKhoshfetrat

View GitHub Profile
@NaserKhoshfetrat
NaserKhoshfetrat / AES.java
Created November 11, 2021 10:00 — forked from Anass-ABEA/AES.java
AES ENCRYPTION
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import java.util.Base64;
/**
* Possible KEY_SIZE values are 128, 192 and 256
* Possible T_LEN values are 128, 120, 112, 104 and 96
*/
@NaserKhoshfetrat
NaserKhoshfetrat / RSA.java
Created November 11, 2021 09:57 — forked from Anass-ABEA/RSA.java
helper methods to encode and decode Strings using the Base64 encoder and decoder
import javax.crypto.Cipher;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Base64;
/**
* @author Anass AIT BEN EL ARBI
* <ul>
@NaserKhoshfetrat
NaserKhoshfetrat / scan-revs
Created September 13, 2021 09:00 — forked from timabell/scan-revs
scan git revision list for bug #s in the comments
#!/bin/bash
#scan revision list for bug #s in the comments
#convert into comma separated values
bugs=`git log $1..$2 --pretty=oneline | grep -o " bug *[0-9]*" | \
cut -d " " -f 3 | sort -n | uniq | while read x; do echo -n $x,; done;`
#strip final comma
bugs=${bugs%,}
@NaserKhoshfetrat
NaserKhoshfetrat / PageDataExtensions.cs
Created September 13, 2021 09:00 — forked from timabell/PageDataExtensions.cs
PageDataExtensions for making it easier to work with EpiServer 6.1 pages
using System;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAccess;
using EPiServer.Security;
using EPiServer.Web.Hosting;
namespace EpiServerShine
{
static internal class PageDataExtensions
@NaserKhoshfetrat
NaserKhoshfetrat / NodeEntryCollection.cs
Created September 13, 2021 09:00 — forked from timabell/NodeEntryCollection.cs
hierarchy reader from stack overflow
using System.Collections.Generic;
namespace util
{
/// <summary>
/// Storage and parsing of flat string based folder hierarchy.
/// See http://stackoverflow.com/a/8621711/10245
/// </summary>
/// <example><code>
/// NodeEntryCollection cItems = new NodeEntryCollection();
@NaserKhoshfetrat
NaserKhoshfetrat / missing-keys.sql
Created September 13, 2021 09:00 — forked from timabell/missing-keys.sql
sql server - find tables / fields with missing keys
-- http://richarddingwall.name/2008/12/21/find-missing-foreignprimary-keys-in-sql-server/
-- Find columns on tables with names like FooID or FooCode which should
-- be part of primary or foreign keys, but aren't.
SELECT
t.name AS [Table],
c.name AS [Column],
i.*
FROM
sys.tables t
@NaserKhoshfetrat
NaserKhoshfetrat / SqlExceptionMocker.cs
Created September 13, 2021 09:00 — forked from timabell/SqlExceptionMocker.cs
Workaround completely test-unfriendly sql error classes
using System.Data.SqlClient;
using System.Reflection;
namespace HorribleThingsInHere
{
/// <summary>
/// Workaround completely test-unfriendly sql error classes.
/// Copy-paste from http://stackoverflow.com/a/1387030/10245
/// Adjusted with updates in comments
/// </summary>
@NaserKhoshfetrat
NaserKhoshfetrat / db-backup-utils.sql
Created September 13, 2021 09:00 — forked from timabell/db-backup-utils.sql
Sql for simplifying and automating the process of loading/backing up multiple databases
USE master;
SET NOCOUNT ON
GO
-- Sql for simplifying and automating the process of loading/backing up multiple databases.
-- Optionally override the restored db name.
-- Also has proc for doing an upgrade of a backup file via an intermediate sql server version.
-- The UI for backup/restore in ssms takes many clicks and doesn't remember anything, this
-- script will allow you to codify repetive actions.
@NaserKhoshfetrat
NaserKhoshfetrat / db-backup-utils.sql
Created September 13, 2021 09:00 — forked from timabell/db-backup-utils.sql
Sql for simplifying and automating the process of loading/backing up multiple databases
USE master;
SET NOCOUNT ON
GO
-- Sql for simplifying and automating the process of loading/backing up multiple databases.
-- Optionally override the restored db name.
-- Also has proc for doing an upgrade of a backup file via an intermediate sql server version.
-- The UI for backup/restore in ssms takes many clicks and doesn't remember anything, this
-- script will allow you to codify repetive actions.
@NaserKhoshfetrat
NaserKhoshfetrat / identity-baseline.sql
Created September 13, 2021 09:00 — forked from timabell/identity-baseline.sql
Script to set the minimum id for all tables in a sql server database
/*
Script to set the minimum id for all tables.
Note that new tables get @baseId as the next id, tables that have had data in get @baseId+1. Ref http://stackoverflow.com/a/13303429/10245
*/
set xact_abort on -- automatically rollback on error
set nocount on -- make it easier to spot errors by reducing output verbosity
BEGIN TRAN