Skip to content

Instantly share code, notes, and snippets.

View gimmi's full-sized avatar

Gian Marco Gherardi gimmi

View GitHub Profile
@gimmi
gimmi / Microsoft.PowerShell_profile.ps1
Last active February 17, 2025 17:02
Settings for CMD and PowerShell
# Edit profile with the following command
# notepad $PROFILE
function prompt {
Write-Host -ForegroundColor DarkGray $executionContext.SessionState.Path.CurrentLocation
[char]::ConvertFromUtf32(0x276f) + ' '
}
Invoke-Command -ScriptBlock {
Write-Host " User: " -ForegroundColor DarkGray -NoNewline
import os, glob, shutil, subprocess
base_path = os.path.join(os.getcwd(), 'GesDB')
pkgs_path = os.path.join(base_path, 'packages')
os.path.relpath('c:\sviluppo\dir\packages', 'c:\sviluppo\dir')
for sln_path, directories, files in os.walk(base_path):
if not [f for f in files if f.lower().endswith(".sln")]: continue
@gimmi
gimmi / .gitignore
Last active December 19, 2015 10:59
Python build script
*.pyc
@gimmi
gimmi / IDataRecord to POCO
Created November 21, 2011 21:31
IDataRecord to POCO
private static T DefaultConverter<T>(IDataRecord rec)
{
var obj = Activator.CreateInstance<T>();
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj);
for(int i = 0; i < rec.FieldCount; i++)
{
PropertyDescriptor property = properties.Find(rec.GetName(i), true);
object value = rec.GetValue(i);
if(property != null && value != DBNull.Value)
{
@gimmi
gimmi / jsmake.svn.SvnUtils.js
Created November 16, 2011 08:24
JSMake examples
jsmake.svn = {};
jsmake.svn.SvnUtils = function () {
this._svnVersionPath = 'svnversion';
};
jsmake.svn.SvnUtils.prototype = {
isWorkingFolderClear: function (path) {
var version = this._svnVersion(path);
return !(version.modified || version.switched || version.partial || version.mixed);
},
@gimmi
gimmi / Main.java
Created September 30, 2011 20:04
Invoking Rhino Javascript from Java
package com.github.gimmi.jsmake;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextAction;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.commonjs.module.Require;
import org.mozilla.javascript.tools.ToolErrorReporter;
import org.mozilla.javascript.tools.shell.Global;
import org.mozilla.javascript.tools.shell.QuitAction;
import org.mozilla.javascript.tools.shell.ShellContextFactory;
@gimmi
gimmi / gist:1245381
Created September 27, 2011 15:30
JSMake Git
jsmake.git = {};
jsmake.git.GitUtils = {
getLastCommitInfo: function (gitRepoPath) {
var git = new org.eclipse.jgit.api.Git(new org.eclipse.jgit.storage.file.FileRepository(jsmake.Fs.combinePaths(gitRepoPath, '.git')));
var commit = git.log().call().iterator().next();
return {
message: commit.getFullMessage(),
sha1: commit.getName(),
date: new Date(1000 * commit.getCommitTime())
};
@gimmi
gimmi / gist:1240891
Created September 25, 2011 17:51
Ext.Direct with MVC
/*
First problem: referencing direct action in proxies/FormPanels
When using Ext.Direct with either Ext.data.proxy.Direct or Ext.form.Basic, you have to specify the function directly, so the function MUST previously be defined by calling Ext.direct.Manager.addProvider. This is a problem because normally the call to addProvider comes after the config evaluation.
For example
*/
Ext.create('Ext.data.proxy.Direct', {
api: {
@gimmi
gimmi / Lazy
Created September 17, 2011 08:00
Windsor 3 scoped disposing
[Test]
public void Should_resolve_lazy_components()
{
var container = new WindsorContainer();
container.Register(Component.For<LazyOfTComponentLoader>());
container.Register(Component.For<A>().LifeStyle.Transient);
var a = container.Resolve<A>(); // Ok
var lazyA = container.Resolve<Lazy<A>>(); // Fail
@gimmi
gimmi / gist:1170427
Created August 25, 2011 10:52
qx mixin initialization error
qx.Class.define("MyClass", {
extend: qx.core.Object,
include: [qx.ui.core.MBlocker],
construct: function () {
this.base(arguments);
this.setBlockerColor("#D5D5D5"); // method from mixin
this.setBlockerOpacity(0.5); // method from mixin
}