Skip to content

Instantly share code, notes, and snippets.

View webgio's full-sized avatar

Giorgio Bozio webgio

  • Viva Software
  • Italy
View GitHub Profile
@webgio
webgio / RotativaHQ_header_footer.cs
Last active September 3, 2016 13:45
RotativaHQ header and footer
public static bool PdfContains(byte[] pdfcontent, string text)
{
using (var pdfReader = new PdfReader(pdfcontent))
{
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
var strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(
pdfReader, page, strategy);
@webgio
webgio / hof.cs
Last active January 26, 2017 09:55
High order function in C#
void Main()
{
var add4To = AddNumber(4);
var newNumber = add4To(3);
Console.WriteLine(newNumber);
// prints 7
}
public Func<int, int> AddNumber(int n)
{
@webgio
webgio / index.html
Created April 4, 2017 15:26
Backbone DEMO Backbone JS Demo // source http://jsbin.com/cihimiq
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Backbone JS Demo" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script>
<meta charset=utf-8 />
<title>Backbone DEMO</title>
[{
"title": "First Block",
"images": [
"https://1.img-dpreview.com/files/p/TS1200x900~sample_galleries/4783759740/0935322774.jpg"
, "https://3.img-dpreview.com/files/p/TS1200x900~sample_galleries/4783759740/7732391852.jpg"
, "https://1.img-dpreview.com/files/p/TS1200x900~sample_galleries/4783759740/6412900034.jpg"
]
},
{
"title": "Second Block",
@webgio
webgio / dapperRun.cs
Last active June 9, 2017 09:27
run with dapper (and NHibernate session and ransaction)
public void RunInSql(Action<IDbConnection, IDbTransaction> action)
{
using (var connection = session.Connection)
{
using (var transaction = GetTransaction(session))
{
try
{
action(connection, transaction);
transaction.Commit();
@webgio
webgio / fulltext_status.sql
Last active August 8, 2019 13:47
How do I list all tables / columns in my SQL server / Azure database that have a full-text index
SELECT name, case FULLTEXTCATALOGPROPERTY(name, 'PopulateStatus')
when 0 then 'Idle'
when 1 then ' Full population in progress'
when 2 then ' Paused'
when 3 then ' Throttled'
when 4 then ' Recovering'
when 5 then ' Shutdown'
when 6 then ' Incremental population in progress'
when 7 then ' Building index'
when 8 then ' Disk is full. Paused.'