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 / app.coffee
Last active December 10, 2023 10:24
Marionette.js module to manage authentication. Needs a server method that checks credentials returning true or false. Started from this blog post code: http://clintberry.com/2012/backbone-js-apps-authentication-tutorial/
App = new Marionette.Application();
App.addRegions {
"headerRegion": "#header"
"topMenuRegion": "#top-menu"
"mainRegion" : "#main"
}
App.on 'initialize:after', ->
Backbone.history.start()
@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.'
@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();
[{
"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 / 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>
@webgio
webgio / node-watch-for-handlebars.js
Last active February 1, 2017 13:44
Node.js script to watch a dir to compile Handlebars.js templates. Needs "npm install watch". Usage: node node-watch-for-handlebars.js [template-dir-to-watch] [optional outputdir]
watch = require('watch');
fs = require('fs');
var cmd = require('child_process').spawn('cmd'), myArgs;
console.log('watcher started');
myArgs = process.argv.slice(2);
myDir = myArgs[0];
outDir = myArgs[1] || '';
outDir = stripTrailingSlash(outDir);
@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)
{
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 / RotativaHQ_header_footer.cs
Last active September 3, 2016 13:45
RotativaHQ header and footer
@webgio
webgio / index.html
Last active December 17, 2015 22:59
coffee pastry widget
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="js/lib/jquery.js"></script>
<script type="text/javascript" src="js/lib/underscore-min.js"></script>
<script type="text/javascript" src="js/lib/backbone.js"></script>
<script type="text/javascript" src="js/lib/backbone.marionette.js"></script>
<script type="text/javascript" src="js/lib/handlebars.js"></script>
<script type="text/javascript" src="js/widget.js"></script>
<title>testing widget</title>