working on it ...

Filters

Explore Public Snippets

Sort by

Found 61k snippets matching: get

    public by lbottaro  529699  10  8  0

    How to get the list of all the activities comparing two UCM streams in python

    This script shows how to get the list of all the activities comparing two ucm streams. The command returns a list object you can easily loop and print.
    import os
    
    bl_old="myOldBaseline@/MyVobs"
    bl_new="myNewBaseline@/MyVobs"
    myView = "MyView"
    
    diff_act=os.popen("cleartool setview -exec \"cleartool diffbl -nmerge -activities "+bl_old+" "+ bl_new+" \" " +myView).readlines()
    
    for act in diff_act:
      print ("ACTIVITY: "+str(act))
    

    public by lbottaro  311387  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 lbottaro  341352  3  7  1

    How to checkout the latest tag of a Git repository

    This simple bash script allows to automatically checkout your local git repository on the latest tagged version available on the remote repository. The script assumes to be run from your local repo. The command 'git rev-list --tags' lists the tags IDs in reverse chronological order, getting the very last one on top. The command 'git describe
    # Get new tags from the remote
    git fetch --tags
     
    # Get the latest tag name
    latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
     
    # Checkout the latest tag
    git checkout $latestTag  

    public by mirage3d  289814  9  4  0

    Get localised country list from Cocoa in Swift

    import Cocoa
    
    let currentLocale = NSLocale.currentLocale()
    let countryCodes = NSLocale.ISOCountryCodes()
    let countryNames = countryCodes.map { currentLocale.displayNameForKey(NSLocaleCountryCode, value: $0) }
    	.filter { $0 != nil }
    	.sort(<)

    public by cghersi  264228  2  5  0

    Bash command to get current directory

    VAR_NAME=$(pwd)

    public by JMichaelTX  263312  0  3  0

    JXA Functions to Get and Set Keyboard Maestro (KM) Variables using JavaScript for Automation (JXA)

    JXA Functions to Get and Set Keyboard Maestro (KM) Variables using JavaScript for Automation (JXA): Get & Set Functions for KM Variables JXA.js
    //=====================================================================	
    function setKMVar(pstrName, pstrValue) {
    //=====================================================================	
    
    	var app = Application.currentApplication()
    	app.includeStandardAdditions = true
    
    	var appKM = Application("Keyboard Maestro Engine")
    		
    	var oVars = appKM.variables
    		
    	try {
    		oVars[pstrName].name();
    		
    	} catch (e) {
    		appKM.variables.push(appKM.Variable({'name': pstrName	}));
    		
    		app.displayNotification(
    			pstrName, 
    			{
    				withTitle: "Set KM Variable",
    				subtitle:  "Variable was Created",
    				soundName: "Basso"
    		  });
    
    		}	// END try/catch
    		
    		oVars[pstrName].value = pstrValue
    		
    		return
    		
    }	// END function setKMVar
    //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
    
    //=====================================================================	
    function getKMVar(pstrName) {
    //=====================================================================	
    
    	var app = Application.currentApplication()
    	app.includeStandardAdditions = true
    
    	var appKM = Application("Keyboard Maestro Engine")
    		
    	var oVars = appKM.variables
    		
    	try {
    		var strValue = oVars[pstrName].value();
    		
    	} catch (e) {
    		
    		strValue = undefined
    		
    		app.beep()
    		var oAns = app.displayAlert('KM Variable does NOT exist', {
    				message: 'Var Name: ' + pstrName,
    				as: 'critical'
    			})
    
    		}	// END try/catch
    				
    		return strValue
    		
    }	// END function getKMVar
    //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
    
    
    

    public by MoonDevilzzz  263826  1  6  0

    Bitrix Api CIBlockElement::GetList

    Bitrix Api CIBlockElement::GetList
    <?
    $arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM","PROPERTY_*");//IBLOCK_ID и ID обязательно должны быть указаны, см. описание arSelectFields выше
    $arFilter = Array("IBLOCK_ID"=>IntVal($yvalue), "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
    $res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
    while($ob = $res->GetNextElement()){ 
     $arFields = $ob->GetFields();  
    print_r($arFields);
     $arProps = $ob->GetProperties();
    print_r($arProps);
    }
    ?>

    public by huanshuai  219447  1  6  1

    Get logging config and start logging in Python

    import logging
    import os.path
    
    SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
    
    def main():
        log_path = os.path.join(SCRIPT_DIR, 'logging.conf')
        logging.config.fileConfig(log_path, disable_existing_loggers=False)
        logger.info("start logging!")
    

    public by dave83  223910  8  7  0

    How to run methods in class marked with specific Java annotation

    The snippet shows how to invoke only methods of a class marked with specific annotation. The list of methods class (MyTest) is returned using reflection. Annotations are returned via getAnnotation() method. The method is executed via invoke() method.
    import java.lang.reflect.Method;
    
    public class MyTest {
    
        @MyAnnotation
        public void method1() {
          System.out.println("method1");
        }
    
        public void method2() {
          System.out.println("method2");
        }
        
        @MyAnnotation
        public void method3() {
          System.out.println("method3");
        }
        
        public static void main(String[] args) {
    
            MyTest runner = new MyTest();
            Method[] methods = runner.getClass().getMethods();
    
            for (Method method : methods) {
                MyAnnotation annos = method.getAnnotation(MyAnnotation.class);
                if (annos != null) {
                    try {
                        method.invoke(runner);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    } 
                            

    public by lbottaro  172543  10  6  0

    curl to send a GET HTTP request with query parameters

    Try to perform a GET HTTP to snip2code server, to list the public snippets in Channels. URL example to get: https://www.snip2code.com/Explore/InChannel?q=test&sort=0&direction=1 Options: -d: list all query parameters -G: perform GET verb
    curl -v -L -G -d "q=test&sort=0&direction=1" https://www.snip2code.com/Explore/InChannel                               
    • Public Snippets
    • Channels Snippets