working on it ...

Filters

Explore Public Snippets

Sort by

Found 9,887 snippets matching: address

    public by lbottaro  311400  3  6  0

    Get MAC address of current interface in Python

    This python uses uuid.getnode to get current mac address as an integer. It formats the number in a standard mac address form (i.e. bytes splitted by :)
    import uuid
    print ':'.join(['{:02x}'.format((uuid.getnode() >> i) & 0xff) for i in range(0,8*6,8)][::-1])
    

    public by pplant  298667  3  6  2

    Simple e-mail validator

    This is a simple email validator which can be used in forms to check whether a given email address is valid or not.
    public static boolean isValidEmailAddress(String email) {
    	   boolean result = true;
    	   try {
    	      InternetAddress emailAddr = new InternetAddress(email);
    	      emailAddr.validate();
    	   } catch (AddressException ex) {
    	      result = false;
    	   }
    	   return result;
    }
    

    public by lbottaro  294404  1  6  3

    Simple RMI Java client

    This is a simple RMI client implementation. Here the client program obtains a stub for the registry on the server's host, then looks up the remote object's stub by name in the registry. Finally invokes the sayHello method on the remote object using the stub. Here the client invokes the method exposes by Hello remote interface. Note that if no
    package example.hello;
    
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    
    public class Client {
    
        private Client() {}
    
        public static void main(String[] args) {
    
    	String host = (args.length < 1) ? null : args[0];
    	try {
    	    Registry registry = LocateRegistry.getRegistry(host);
    	    Hello stub = (Hello) registry.lookup("Hello");
    	    String response = stub.sayHello();
    	    System.out.println("response: " + response);
    	} catch (Exception e) {
    	    System.err.println("Client exception: " + e.toString());
    	    e.printStackTrace();
    	}
        }
    }    

    public by Geometry  87824  2  4  0

    PubKeyToScript: For POS coins - used to format wallet address pubkey to use in generation transaction's output.

    For POS coins - used to format wallet address pubkey to use in generation transaction's output. nodejs: https://github.com/zone117x/node-stratum-pool/blob/3586ec0d7374b2acc5a72d5ef597da26f0e39d54/lib/util.js#L243 nodejs: http://runnable.com/me/VCFHE0RrZnwbsQ6y
    using System;
    using System.IO;
    using System.Linq;
    using CoiniumServ.Coin.Address;
    using CoiniumServ.Coin.Address.Exceptions;
    using CoiniumServ.Cryptology;
    using CoiniumServ.Utils.Extensions;
    using CoiniumServ.Utils.Numerics;
    using Gibbed.IO;
    using Serilog;
    
    /// <summary>
    /// For POS coins - used to format wallet address pubkey to use in generation transaction's output.
    /// </summary>
    /// <param name="key"></param>
    /// <example>
    /// nodejs: https://github.com/zone117x/node-stratum-pool/blob/3586ec0d7374b2acc5a72d5ef597da26f0e39d54/lib/util.js#L243
    /// nodejs: http://runnable.com/me/VCFHE0RrZnwbsQ6y
    /// </example>
    /// <returns></returns>
    public static byte[] PubKeyToScript(string key)
    {
        var pubKey = key.HexToByteArray();
    
        if (pubKey.Length != 33)
        {
            Log.Error("invalid pubkey length for {0:l}", key);
            return null;
        }
    
        byte[] result;
    
        using (var stream = new MemoryStream())
        {
            stream.WriteValueU8(0x21);
            stream.WriteBytes(pubKey);
            stream.WriteValueU8(0xac);
            result = stream.ToArray();
        }
    
        return result;
    }

    public by p.kontalis  99071  2  5  0

    VTiger Extraction Customers' Data by City

    Extract from Vtiger Customers' List with address and to whom they have been assigned
    SET @city = '[CITY NAME]'; #Replace [CITY NAME] with your preferable city name
    SET @db_name='[DATABASE NAME]'; #Replace [DATABASE NAME] with your database name
    SET @myquery = CONCAT('
    SELECT	', @db_name, '.vtiger_account.accountid AS \'Company Code\',
    		', @db_name, '.vtiger_account.accountname AS \'Company\', 
    		', @db_name, '.vtiger_account.phone AS \'Phone 1\', 
    		', @db_name, '.vtiger_account.otherphone AS \'Phone 2\', 
    		', @db_name, '.vtiger_account.email1 AS \'Email 1\', 
    		', @db_name, '.vtiger_account.email2 AS \'Email 2\', 
    		', @db_name, '.vtiger_account.website AS \'Website\', 
    		', @db_name, '.vtiger_account.fax AS \'Fax\',
    		', @db_name, '.vtiger_accountbillads.bill_city AS \'City\',
    		', @db_name, '.vtiger_accountbillads.bill_code AS \'TK\',
    		', @db_name, '.vtiger_accountbillads.bill_country AS \'Country\',
    		', @db_name, '.vtiger_accountbillads.bill_state AS \'State\',
    		', @db_name, '.vtiger_accountbillads.bill_street AS \'Street\',
    		', @db_name, '.vtiger_accountbillads.bill_pobox AS \'TK\', 
    		', @db_name, '.vtiger_users.last_name AS \'Αssignment το\'
    FROM ', @db_name, '.vtiger_account
    INNER JOIN ', @db_name, '.vtiger_accountbillads 
    ON ', @db_name, '.vtiger_account.accountid = ', @db_name, '.vtiger_accountbillads.accountaddressid
    INNER JOIN ', @db_name, '.vtiger_crmentity
    ON ', @db_name, '.vtiger_account.accountid = ', @db_name, '.vtiger_crmentity.crmid	
    LEFT JOIN ', @db_name, '.vtiger_users
    ON ', @db_name, '.vtiger_crmentity.smownerid = ', @db_name, '.vtiger_users.id
    WHERE ', @db_name, '.vtiger_accountbillads.bill_city=@city
    AND ', @db_name, '.vtiger_crmentity.setype=\'Accounts\' 
    ');
    PREPARE stmt FROM @myquery;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
                
    

    public by micurs  3912  8  8  1

    Change the address in the browser without reloading

    In HTML5 it is possible to change part of the address in the address browser without reloading the page. This helps building single page site with elements of the UI addressable using a consistent URL. See an example here: http://www.usatoday.com/ . By clicking on any article box a popup within the same page shows the content, and the URL in the
    // This add a new state to the browser history and replace the path
    window.history.pushState( stateObj, 'content title', '/new-path');
    
    // This replace the current state to the browser history and replace the path
    window.history.replaceState(stateObj, 'content title', '/new-path');
    

    public by Geometry  1063  0  5  0

    CoinAddressToScript: For POW coins - used to format wallet address for use in generation transaction's output

    For POW coins - used to format wallet address for use in generation transaction's output nodejs: https://github.com/zone117x/node-stratum-pool/blob/dfad9e58c661174894d4ab625455bb5b7428881c/lib/util.js#L264 nodejs: https://codio.com/raistlinthewiz/bitcoin-coinbase-serializer-wallet-address-to-script
    using System;
    using System.IO;
    using System.Linq;
    using CoiniumServ.Coin.Address;
    using CoiniumServ.Coin.Address.Exceptions;
    using CoiniumServ.Cryptology;
    using CoiniumServ.Utils.Extensions;
    using CoiniumServ.Utils.Numerics;
    using Gibbed.IO;
    using Serilog;
    
    /// <summary>
    /// For POW coins - used to format wallet address for use in generation transaction's output
    /// </summary>
    /// <param name="address"></param>
    /// <example>
    /// nodejs: https://github.com/zone117x/node-stratum-pool/blob/dfad9e58c661174894d4ab625455bb5b7428881c/lib/util.js#L264
    /// nodejs: https://codio.com/raistlinthewiz/bitcoin-coinbase-serializer-wallet-address-to-script
    /// </example>
    /// <returns></returns>
    public static byte[] CoinAddressToScript(string address)
    {
        byte[] decoded;
    
        try
        {
            decoded = Base58.Decode(address);
        }
        catch (AddressFormatException)
        {
            Log.Error("Base58 decode failed for address {0:l}", address);
            return null;
        }
    
        if (decoded.Length != 25)
        {
            Log.Error("invalid address length for {0:l}", address);
            return null;
        }
    
        var pubkey = decoded.Slice(1, -4);
    
        byte[] result;
    
        using (var stream = new MemoryStream())
        {
            stream.WriteValueU8(0x76);
            stream.WriteValueU8(0xa9);
            stream.WriteValueU8(0x14);
            stream.WriteBytes(pubkey);
            stream.WriteValueU8(0x88);
            stream.WriteValueU8(0xac);
    
            result = stream.ToArray();
        }
    
        return result;
    }

    public by Geometry  744  0  5  0

    GetIndices: Creates a vector containing every index that can be used to address a given jagged <paramref name="array"/>, in order.

    Creates a vector containing every index that can be used to address a given jagged , in order. The array whose indices will be returned.
    /// <summary>
    ///   Creates a vector containing every index that can be used to
    ///   address a given jagged <paramref name="array"/>, in order. 
    /// </summary>
    /// 
    /// <param name="array">The array whose indices will be returned.</param>
    /// 
    /// <seealso cref="Matrix.GetIndices"/>
    /// 
    public static Tuple<int, int>[] GetIndices<T>(this T[][] array)
    {
        var list = new List<Tuple<int, int>>();
        for (int i = 0; i < array.Length; i++)
            for (int j = 0; j < array[i].Length; j++)
                list.Add(Tuple.Create(i, j));
        return list.ToArray();
    }

    public by Tech_JA  3403  0  6  3

    Set user and email address

    First steps to use Git
    git config --global user.name "your user name"
    git config --global user.email "your email address"

    public by emsity  2177  4  6  0

    RPi Static IP Address on 2 networks Network Interfaces file

    This is the network Interfaces file used to connect via cable to the primary network (192.168.0.12), or via wifi to the secondary network (192.168.169.15) with static ip address
    auto lo
    
    iface lo inet loopback
    iface eth0 inet static
    
    address 192.168.0.12
    netmask 255.255.255.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    
    
    allow-hotplug wlan0
    iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet static
    
    address 192.168.169.15
    netmask 255.255.255.0
    broadcast 192.168.169.255
    gateway 192.168.169.1
    • Public Snippets
    • Channels Snippets