Skip to content

Instantly share code, notes, and snippets.

View vijayantkatyal's full-sized avatar
🙃

Vijayant Katyal vijayantkatyal

🙃
View GitHub Profile
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
public static class DbContextExtensions
{
public static void LogToConsole(this DbContext context)
{
IServiceProvider contextServices = ((IDbContextServices)context).ScopedServiceProvider;
var loggerFactory = contextServices.GetRequiredService<ILoggerFactory>();
loggerFactory.AddConsole(LogLevel.Verbose);
}
}
@vijayantkatyal
vijayantkatyal / convert-mogrify
Last active August 29, 2015 14:19
convert | batch convert ai to png
# single convert
convert -density 150 File.ai preview.png
# batch convert
dir -recurse -include *.ai | %{ mogrify -density 150 -format png $_.FullName }
# run as powershell command (wrap)
powershell -Command 'dir -recurse -include *.ai | %{ mogrify -density 150 -format png $_.FullName }'
@vijayantkatyal
vijayantkatyal / git-folders
Created April 16, 2015 20:32
git add sub folders / current folder
#include current folder only
git add *.png
# include sub folders only
git add **/*.png
# include both current and sub folders
git add *.png
git add **/*.png
@vijayantkatyal
vijayantkatyal / package_sources_example.config
Last active September 6, 2015 19:22
package source example
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2/" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</activePackageSource>
@vijayantkatyal
vijayantkatyal / xbox_retro_pie
Created July 25, 2016 16:27
install xbox one controller driver on retro pie
# Get rpi-source... easier than dkms shenanigans with headers from here
# https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi
sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
# Clean anything from a previous install
sudo rm -rfv /usr/src/4.4.11-v7
sudo install bc
@vijayantkatyal
vijayantkatyal / run_docker
Last active November 28, 2016 00:00
run docker in current directory
// create image (in working directory)
docker run -v "$(pwd):/usr/src/app" -p "4000:4000" starefossen/github-pages
// run container
docker start -i blog
@vijayantkatyal
vijayantkatyal / backup.php
Created December 1, 2016 15:56
Create Backup of folders and database
<?php
// create folder
$backupfile = 'dest_folder_name/file_name_' . date("Y-m-d") . '.tar.gz';
system("tar -czf $backupfile src_folder");
// database backup
$dbhost = "localhost"; // usually localhost
$dbuser = "user_name";
@vijayantkatyal
vijayantkatyal / live.sh
Created May 6, 2017 09:29
Live Video Stream to Facebook
# stream video
ffmpeg -re -i live.mp4 -c:v libx264 -preset veryfast -maxrate 3000k \
-bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 \
-ar 44100 -f flv "rtmp://rtmp-api.facebook.com:80/rtmp/"
# stream desktop
ffmpeg -video_size 1366x768 -framerate 25 -f x11grab -i :0.0 -ar 44100 -f alsa -ac 2 -i hw:0 -preset ultrafast output.mp4 -f flv "rtmp://rtmp-api.facebook.com:80/rtmp/"