Skip to content

Instantly share code, notes, and snippets.

View flashvnn's full-sized avatar

Huynh Khac Thao flashvnn

View GitHub Profile
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active July 14, 2024 19:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@tkhn
tkhn / apache-exclude-urls-basic-auth.conf
Created October 9, 2013 10:33
exclude one url from basic auth with apache
SetEnvIfNoCase Request_URI "^/status\.php" noauth
AuthType Basic
AuthName "Identify yourself"
AuthUserFile /path/to/.htpasswd
Require valid-user
Order Deny,Allow
Deny from all
Allow from env=noauth
@omrico1
omrico1 / yotpobatchexample.php
Last active June 8, 2022 09:55
Yotpo Batch Request and Parsing Example
<?php
//This is an example batch request for app_key GYRCLYSnfHKGlA9iQoYjeVQ0297Fr4kvW5kaZ9Zw, please remember to switch to your own.
$url = 'http://staticw2.yotpo.com/batch';
//Building the batch data
$data = array('methods' => '
[{"method":"main_widget","params":{"pid":"295823037"}},
{"method":"bottomline","params":{"pid":"295823037",
"link":"",
@jameymcelveen
jameymcelveen / StyledRenderer_iOS.cs
Last active August 29, 2015 14:05
Pixate iOS helper for Xamarin.Forms. This class copies style info from Xamarin.Forms elements into the underlying native component.
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using YourProject.iOS;
using System.ComponentModel;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using PixateFreestyleLib;
using Common;
@maximilianschmitt
maximilianschmitt / jobs.js
Created September 3, 2014 23:47
Automated MySQL backups to S3 with node.js
'use strict';
var mysqlBackup = require('./mysql-backup');
var schedule = require('node-schedule');
schedule.scheduleJob({ hour: 22, minute: 0 }, mysqlBackup);
@MitchMilam
MitchMilam / ListViewAlternatingBackgroundColors.cs
Last active August 30, 2023 20:34
Alternating background colors in a Xamarin.Forms ListView
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace XamarinFormsDeepDive
{
class ListViewDemo : ContentPage
{
class Person
{
@geirsagberg
geirsagberg / StoryBoardContainer.cs
Last active November 19, 2015 12:02
MvvmCross load views from Storyboards using a custom attribute
public class StoryBoardContainer : MvxTouchViewsContainer
{
protected override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request)
{
var storyboardAttribute = viewType.GetCustomAttribute<FromStoryboardAttribute>();
if (storyboardAttribute != null) {
var storyboard = UIStoryboard.FromName(storyboardAttribute.StoryboardName ?? viewType.Name, null);
var viewController = storyboard.InstantiateViewController(viewType.Name);
return (IMvxTouchView) viewController;
}
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Markup;
using Cirrious.CrossCore.Wpf.Converters;
using Cirrious.MvvmCross.Localization;
@rid00z
rid00z / AsyncHelper.cs
Created September 19, 2015 03:11
This code can be used to task a async task and run it without the async part.
public static class AsyncHelper
{
private static readonly TaskFactory _myTaskFactory = new
TaskFactory(CancellationToken.None,
TaskCreationOptions.None,
TaskContinuationOptions.None,
TaskScheduler.Default);
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
{
@harish2704
harish2704 / lodash.get.js
Last active June 3, 2023 23:41
Simple lodash.get function in javascript
/* Implementation of lodash.get function */
function getProp( object, keys, defaultVal ){
keys = Array.isArray( keys )? keys : keys.split('.');
object = object[keys[0]];
if( object && keys.length>1 ){
return getProp( object, keys.slice(1) );
}
return object === undefined? defaultVal : object;
}