working on it ...

Filters

Explore Public Snippets

Sort by

Found 20k snippets matching: current

    public by lbottaro  901715  60  8  1

    How to remove all checked out files in clearcase

    This cleartool command lists all the checkout files (both from the current directory and from the entire view) searching in each directory or vob path. For each element found, it invokes the command to remove the checkout.
    # Remove ALL checked out files from view in the entire vobs
    cleartool lsco -cview -me -avobs -short | xargs cleartool unco -rm 
    
    # Remove ALL checked out files from the current directory on only
    cleartool lsco -cview -me -rec -short | xargs cleartool unco -rm 

    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 cghersi  264264  2  5  0

    Bash command to get current directory

    VAR_NAME=$(pwd)

    public by AnghelLeonard  212386  3  5  0

    Hibernate JPA - programmatically set the transaction isolation level for the current connection

    Hibernate JPA - programmatically set the transaction isolation level for the current connection
    entityManager = entityManagerFactory.createEntityManager();
                Session session = (Session) entityManager.getDelegate();            
                session.doWork((Connection connection) -> {
                    connection.setTransactionIsolation(
                            Connection.TRANSACTION_READ_COMMITTED);
                });

    public by Charles Peter Nystrom  202189  3  3  0

    Replace string in all files within the current directory. - PowerShell

    Replace string in all files within the current directory. - PowerShell: gistfile1.txt
    $stringToReplace = "foo"
    $replaceWith = "bar"
    Get-ChildItem | ForEach-Object{ $pathToFile = $_.FullName; (get-content $pathToFile) | % { $_ -replace $stringToReplace, $replaceWith } | set-content $pathToFile }
    
    

    public by cghersi  173426  8  7  0

    Nice way to show the current time of day

    Current Time printed in a nice way
    public static string NiceCurrentTime()
    {  
      int hour = DateTime.Now.Hour;
    
      if (hour <= 5)
        return "this night oh yeah";
      else if (hour > 5 && hour <= 12)
        return "this morning";
      else if (hour > 12 && hour < 18)
        return "this afternoon";
      else 
        return "this evening";
    }                                                                                    

    public by coaster3000  212292  0  4  0

    Setup's up a new debug setup for BukkitPlugins. Currently WIP.

    Setup's up a new debug setup for BukkitPlugins. Currently WIP.: dev.sh
    #!/bin/bash
    
    #Bases Config
    JAR_EXT=".jar"
    
    WORKSPACE="/home/ChrisKrier/workspace" #DEFAULT VALUE
    SERVER="/MCTestServer" #Test Server
    
    JARS=()
    
    setup() {
    	echo Setting up the environment please wait.
    	echo 
    	echo
    	echo Checking for server jar
    	
    }
    
    
    
    setdev() {	
    	helpset() {
    			cat <<EOF
    
    usage: setdev options
    
    This script will fetch an artifact from a Nexus server using the Nexus REST redirect service.
    
    OPTIONS:
       -?
       -h      Show this message
       -s      Sets the server directory to specified value
       -w     Sets the workspace directory to specified value
       -d      Displays currently set settings.
    
    EOF
    	}
    	
    	# A POSIX variable
    	OPTIND=1         # Reset in case getopts has been used previously in the shell.
    	
    	while getopts "h?w:s:d" opt; do
    		case "$opt" in
    		h|\?)
    			helpset
    			return 0
    			;;
    		w)
    			WORKSPACE="$OPTARG"
    			echo Workspace set to "$OPTARG"
    			;;
    		s)
    			SERVER="$OPTARG";
    			echo Server set to "$OPTARG"
    			;;
    		d)
    			cat <<EOF
    
    Current Settings
    X------------------------------------------------------------------------------
    | SERVER	=	$SERVER
    | WORKSPACE	=	$WORKSPACE
    X------------------------------------------------------------------------------
    
    EOF
    			return 0
    			;;
    		?)
    			helpset
    			return 0
    			;;
    			
    		esac
    	done;
    	
    	shift $((OPTIND-1))
    	
    	if [[ -z "$1" ]]
    	then {
    		helpset
    		return 0
    	}
    	fi
    	
    }
    
    ## JAR SCANNING
    
    scanJars() {
    	echo Scanning for jars in $WORKSPACE
    	shopt -s globstar
    	local LAST=`PWD`
    	cd $WORKSPACE
    	for i in $(find **/*.jar)
    	do 
    		JARS+=($i);
    	done;
    	cd $LAST
    }
    
    printJars() {
    	printf "%s\n" "${JARS[@]}"
    }
    
    editdev() {
    	local LAST=`PWD`
    	cd ~/
    	run "C:\wscite\SciTE.exe" dev.sh
    	cd $LAST
    }
    
    restart() {
    	exec $(ls -l /proc/$$/exe | sed 's%.*/%%')
    }
    
    setup & scanJars
    wait #Wait until we are done our tasks to allow control
    clear
    echo We are now awaiting orders captain!
    
    

    public by fabio.nosenzo  6547  1  7  1

    Get Current Date In VBA

    How to use date function for getting date in VBA Excel. In VBA you can't use today() function but you can use date ()
    ' In VBA you can't use today() function
    ' instead you have to use date ()
    
    'get today date:
    Cells (1,1) = Date
    
    'get yesterday date:
    Cells (1,1) = Date - 1

    public by kanishka  2389  0  5  0

    User Current Location

    Get Users current Location
    - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
        NSLog(@"didFailWithError: %@", error);
        UIAlertView *errorAlert = [[UIAlertView alloc]
                                   initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [errorAlert show];
    }
    
    
    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
    {
        NSLog(@"didUpdateToLocation: %@", newLocation);
        CLLocation *currentLocation = newLocation;
        
        AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
        
        //appDelegate.location = currentLocation;
        
        [self notifyLocationUpdate];
        
        // Stop Location Manager
        //[appDelegate stopNotifyingLocation];
    }
    
    // Delegate method from the CLLocationManagerDelegate protocol.
    - (void)locationManager:(CLLocationManager *)manager
         didUpdateLocations:(NSArray *)locations {
        
        // If it's a relatively recent event, turn off updates to save power
        CLLocation* location = [locations lastObject];
        
        NSLog(@"latitude %+.6f, longitude %+.6f\n",
                     location.coordinate.latitude,
                     location.coordinate.longitude);
        
    }           

    public by cghersi  4890  7  7  1

    IntelliJ: How to programmatically retrieve information like language, OS, Architecture, etc. regarding the current project

    This is the fastest method to retrieve information regarding your project and current file, if you are developing an IntelliJ plugin.
    public void actionPerformed(AnActionEvent event) {
    	com.intellij.openapi.actionSystem.DataContext dataContext = event.getDataContext();
    	
    	//retrieve the current file selected in the editor:
    	com.intellij.openapi.vfs.VirtualFile currentFile = null;
    	if (dataContext != null) 
    		currentFile = DataKeys.VIRTUAL_FILE.getData(dataContext);
    
    	com.intellij.openapi.project.Project project = event.getData(PlatformDataKeys.PROJECT);
    	String jvmVersionName = "";
    	if (project != null) {
    		com.intellij.openapi.roots.ProjectRootManager rootMan = 
    			com.intellij.openapi.roots.ProjectRootManager.getInstance(project);
    		if (rootMan != null) {
    			com.intellij.openapi.projectRoots.Sdk projectSdk = rootMan.getProjectSdk();
                   if (projectSdk != null) {
    				String ver = projectSdk.getVersionString(); //this is something like "java version "jdk1.7.045""
    				if (ver != null) {
    					System.out.println("Found Version string:" + ver);
                       }
    			}
    		}
    	}
    }
    • Public Snippets
    • Channels Snippets