Skip to content

Instantly share code, notes, and snippets.

View lazarofl's full-sized avatar
🏃‍♂️

Lazaro Fernandes Lima Suleiman lazarofl

🏃‍♂️
View GitHub Profile
@lazarofl
lazarofl / renderaview.cs
Created March 28, 2013 12:28
Render a partial view to a variable in ASP.NET MVC
using (StringWriter sw = new StringWriter())
{
ViewData.Model = oCalendarEvent;
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, "_PARTIALVIEWNAME");
ViewContext viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
viewResult.View.Render(viewContext, sw);
eventView = sw.GetStringBuilder().ToString().RemoveAll("\r\n");
}
@lazarofl
lazarofl / mysqlbackuptoamazons3.sh
Last active December 14, 2015 23:19
MySql backup to amazon S3
#!/bin/bash
# mongodump reference: http://www.nacaolivre.com.br/servidor/mysql-backup-com-mysqldump/
# Author: Lazaro Lima - www.lazarolima.com.br
#
S3_BUCKET_NAME="condomundo-databases-snapshots"
S3_BUCKET_PATH="mysql-backups"
MYSQLROOT="yourUserName"
MYSQLPASS="yourPassword"
@lazarofl
lazarofl / a_mongodb_to_s3_backup.sh
Last active April 19, 2022 05:06
MongoDB Automatic Backup to Amazon S3 with Crontab and s3cmd. Red Hat Linux on Amazon EC2
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"
@lazarofl
lazarofl / geocoder_example.html
Created October 16, 2012 18:27
Google Maps V3 - Geocoder example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Google Maps JavaScript API v3 Example: Geocoding Simple</title>
<link href="https://developers.google.com/maps/documentation/javascript/examples/default.css" rel="stylesheet">
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
@lazarofl
lazarofl / global.asax
Created October 10, 2012 17:20
Global.asax with route tables for url rewriting
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script RunAt="server">
/// <summary>
/// Add routes to application
/// </summary>
void RegisterRoutes(RouteCollection routes)
{
#region Rotas amigáveis