Skip to content

Instantly share code, notes, and snippets.

View priyankadavle's full-sized avatar

priyankadavle

View GitHub Profile
public string deleteFiles = "data";
File.WriteAllText("outputs.json", JsonConvert.SerializeObject(new { deletedFile = deleteFiles }));
@priyankadavle
priyankadavle / gist:d45db5b712df74708bf12223646b37dc
Created July 16, 2020 16:19
Get bin folder path C# (get release folder path)
var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
path = path.Substring(6);
@priyankadavle
priyankadavle / gist:5ba9450fb92af1fb0daa5fe1bad07486
Last active July 17, 2020 16:31
Call exe from console application (call one exe from other exe) C#
Process p = new Process();
p.StartInfo.FileName = "cmd.exe"; <-- This will call your exe (replace your exe with cmd.exe)
p.StartInfo.Arguments = "/c dir *.cs"; <-- You will be calling Static Main method of cmd.exe which may requier args[]
So, pass them here with space separated form
(Example: you need to send 3 args then pass like this: "arg1 arg2 arg3")
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
Console.WriteLine(p.StandardOutput.ReadToEnd()); <-- This line will get console data from cmd.exe project to your application console
@priyankadavle
priyankadavle / LoadUrlHtmltoTag.js
Created March 30, 2020 14:56
Load Url Html to Tag
Using simple html,
<div>
<object type="text/html" data="http://validator.w3.org/" width="800px" height="600px" style="overflow:auto;border:5px ridge blue">
</object>
</div>
Or jquery,
<script>
$("#mydiv")
@priyankadavle
priyankadavle / Close btn css
Created March 30, 2020 14:55
Close Btn Css
a.boxclose{
float:right;
margin-top:-30px;
margin-right:-30px;
cursor:pointer;
color: #fff;
border: 1px solid #AEAEAE;
border-radius: 30px;
background: #605F61;
font-size: 31px;
// User can be part of many groups
const user = {
groups: ["group2"]
};
// Roles can have many groups
// What you see here is the output or 2 different data source
// Thats why we have group duplication inside different role
const roles = [{
name: "role1",
<span id='close' onclick='this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;'>x</span>
Css for close button
#close {
float:right;
display:inline-block;
padding:2px 5px;
private AccountController GetAccountController ()
{
.. setup mocked services..
var accountController = new AccountController (..mocked services..);
var controllerContext = new Mock<ControllerContext> ();
controllerContext.SetupGet(p => p.HttpContext.Session["test"]).Returns("Hello World");
controllerContext.SetupGet(p => p.HttpContext.User.Identity.Name).Returns(_testEmail);
controllerContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
https://stackblitz.com/github/codecraft-tv/angular-course/tree/current/8.pipes/2.built-in-pipes/code
// Code source is from this awesome blog:
// http://pfelix.wordpress.com/2012/11/27/json-web-tokens-and-the-new-jwtsecuritytokenhandler-class/
class Program
{
static void Main(string[] args)
{
var securityKey = GetBytes("ThisIsAnImportantStringAndIHaveNoIdeaIfThisIsVerySecureOrNot!");
var tokenHandler = new JwtSecurityTokenHandler();