working on it ...


Explore Public Snippets

Sort by

Found 8,915 snippets matching: path

    public by lbottaro  901724  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 fabio.nosenzo @ Amazon_AWS_Python_API  588235  5  8  -1

    Amazon S3 Aws - S3Connection object from python boto API

    This snippet is about the S3Connection object provided by python boto package for Amazon AWS API. Here the __init__ method is listed with all its variables. The AWSAuthConnection object is initialized and it handles all the data for managing requests and response from Amazon AWS service. Path: [boto/s3/] Learn more about S3Con
    import boto.utils
    from boto.connection import AWSAuthConnection
    class S3Connection(AWSAuthConnection):
        DefaultHost = boto.config.get('s3', 'host', '')
        DefaultCallingFormat = boto.config.get('s3', 'calling_format', 'boto.s3.connection.SubdomainCallingFormat')
        QueryString = 'Signature=%s&Expires=%d&AWSAccessKeyId=%s'
        def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                     is_secure=True, port=None, proxy=None, proxy_port=None,
                     proxy_user=None, proxy_pass=None,
                     host=DefaultHost, debug=0, https_connection_factory=None,
                     calling_format=DefaultCallingFormat, path='/',
                     provider='aws', bucket_class=Bucket, security_token=None,
                     suppress_consec_slashes=True, anon=False,
            if isinstance(calling_format, str):
            self.calling_format = calling_format
            self.bucket_class = bucket_class
            self.anon = anon
            AWSAuthConnection.__init__(self, host,
                    aws_access_key_id, aws_secret_access_key,
                    is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
                    debug=debug, https_connection_factory=https_connection_factory,
                    path=path, provider=provider, security_token=security_token,

    public by lbottaro @ Amazon_AWS_Python_API  304500  0  8  0

    Amazon S3 Aws - How to download a file from a bucket to a target directory

    This code shows how to download a file from an existing bucket invoking the boto python API, saving to a target directory. You need to specify the filename and path where to save the data. [How to create a bucket]( [How to upload a file to a bucket](
    # This downloads the object foobar.pdf and saves it in /home/luca/documents/
    key = bucket.get_key('foobar.pdf')

    public by DanielOgbuagu  201754  1  5  0

    Adding a *.jar file (originating from java-wrapped C++ code) to an SBT project classpath

    I thought using unmanaged dependencies in SBT projects was simply dropping a jar file into the lib directory, until I bought an SDK for a biometric device. Both the C++ and the Java packages were provided. I opted for the Java package, copying the provided jar file and the JNI (*.so) files into the appropriate locations and configuring the ja
     * In my <code>build.sbt</code> file, I appended a blank line and then the following:
    libraryDependencies += "groupID" % "artifactId" % "revision" from "file:///home/Danogbuagu/Projects/biometric-lib/filename.jar"
    // where,
    // groupID for example is like: com.zigzagcompany 
    // artifactId for example is like: zigzag
    // revision for example is like: 1.3.4
    // Remember the line befor the code and that after.

    public by cghersi  9860  3  9  1

    C#: How to Convert a generic Url to absolute Uri

    This method provides an Uri object from the given URL, splitted as baseURl and extracted url, e.g. baseURL='', extractedUrl='./Snippet/25652'
    /// <summary>
    /// Converts a generic Url to absolute Uri
    /// </summary>
    /// <param name="baseUrl">The main url of the website</param>
    /// <param name="extractedUrl">The url to be converted</param>
    /// <returns>An absolute Uri | null</returns>
    /// -----------------------------------------------------------------------------------------------------
    static public Uri UriAbsoluteFromUrl(string baseUrl, string extractedUrl)
        // The URI is in a HTTP page and could have encoded HTML char ...
        string link = HttpUtility.HtmlDecode(extractedUrl.Replace("\n", ""));
        Uri baseUri = new Uri(baseUrl);
        string siteRoot = string.Empty;
        // create absolute link
        if (link.StartsWith("/"))
            //absolute replace
            int firstSlashPos = baseUrl.IndexOf("://");
            string protocol = baseUrl.Substring(0, firstSlashPos + 3);
            Uri siteRef = new Uri(baseUrl.Trim());
            link = string.Concat(protocol, siteRef.Host, link.Trim());
        else if (link.StartsWith("./"))
            //relative replace - same level
            siteRoot = baseUrl.Trim();
            siteRoot = siteRoot.TrimEnd('/');
            link = string.Format("{0}/{1}", siteRoot, link.TrimStart('.', '/'));
        else if (link.StartsWith("../"))
            //relative replace - multi level                                
            siteRoot = baseUrl.Trim();
            string clean = link;
            while (clean.StartsWith("../"))
                clean = clean.Remove(0, 3);
                siteRoot = siteRoot.TrimEnd('/');
                siteRoot = siteRoot.Substring(0, siteRoot.LastIndexOf('/'));
            link = string.Format("{0}/{1}", siteRoot, clean.TrimStart('/'));
        else if (!link.Contains("://"))
            //relative replace - same level
            baseUrl += "/";
            int lastSlash = baseUrl.LastIndexOf('/');
            if (lastSlash > 0 && lastSlash < baseUrl.Length)
                siteRoot = baseUrl.Substring(0, lastSlash);
            siteRoot = siteRoot.TrimEnd('/');
            link = string.Format("{0}/{1}", siteRoot, link.TrimStart('.', '/'));
        // escape the link
        if (!Uri.IsWellFormedUriString(link, UriKind.Absolute))
            link = Uri.EscapeUriString(link);
        if (Uri.IsWellFormedUriString(link, UriKind.Absolute))
            return new Uri(link);
            return null;

    public by cghersi  4333  6  6  2

    Move a file to another location in SQL Server

    Here is the procedure to move a file to another location (e.g. for the database called MyDB). First you need to execute the first part of this snippet (until the comment '/**** Now you need to physically move the file to the other location ***/'). Then you need to move the file and eventually you can execute the last two statements.
       Name = MyDB_file1,
       Filename = 'c:\DB\MyDB.mdf'
    /**** Now you need to physically move the file to the other location ***/

    public by cghersi  2291  0  6  0

    Retrieve the path of a resource inside an Eclipse plugin

    /** * Retrieves the root path for the specified file * @param bundleName name of the bundle containing the file * @param fileName name of the file to search * @return string empty if any error occurred; the full directory path of the specified file otherwise */
    public static String getResourcePath(String bundleName, String fileName) {
    	Bundle bundle = Platform.getBundle(bundleName);
    	URL fileURL = bundle.getEntry(fileName);
    	File file = null;
    	try {
    		URL resolvedUrl = FileLocator.resolve(fileURL);
    		file = new File(resolvedUrl.getFile());
    	} catch (IOException e1) {
    	if (file == null) {
    		System.err.println("Cannot find configuration files");
    		return "";
    	return file.getParent();

    public by jamesmoey  4375  0  4  0

    Destination path already exist var/www/xxxx already exist, is not an empty directory

    Hi. I am trying to clone git repo with some other roles like nginx, composer etc. But when i reach to the point of cloning repos, I got error that destination path already exist /var/www/xxxx already exist is not an empty directory. Here is code: - name: Pull sources from GitHub git: repo: "{{ item.github_repo }}" version: "{{ item.g
    // Enter here the actual content of the snippet.            
    Clone into a temporary directory and copy the content into the /var/www/xxx directory

    public by pplant  3806  3  6  1

    Read/Write File in Java

    An easy way to read a file and append text to it
    try {
      File aFile = new File("/Path/to/File/file_name.txt");
      //Set parameter true if you want to append content otherwise false
      BufferedWriter bW = new BufferedWriter(new FileWriter(aFile,true));
      String line = "Text to file";
    } catch (IOException e) {
    	//Put catching code here

    public by merqlove  3982  1  4  0

    Rails engine JS assets route path fix from Spree

    Rails engine JS assets route path fix from Spree:
    #= require jsuri
    class window.Spree
      @ready: (callback) ->
      @mountedAt: ->
        "<%= Rails.application.routes.url_helpers.spree_path %>"
      @pathFor: (path) ->
      # Helper function to take a URL and add query parameters to it
      # Uses the JSUri library from here:
      # Thanks to Jake Moffat for the suggestion:
      @url: (uri, query) ->
        if uri.path == undefined
          uri = new Uri(uri)
        if query
          $.each query, (key, value) ->
            uri.addQueryParam(key, value)
        return uri
      # Helper method in case people want to call uri rather than url
      @uri: (uri, query) ->
        url(uri, query)
      # This function automatically appends the API token
      # for the user to the end of any URL.
      # Immediately after, this string is then passed to jQuery.ajax.
      # ajax works in two ways in jQuery:
      # $.ajax("url", {settings: 'go here'})
      # or:
      # $.ajax({url: "url", settings: 'go here'})
      # This function will support both of these calls.
      @ajax: (url_or_settings, settings) ->
        if (typeof(url_or_settings) == "string")
          $.ajax(Spree.url(url_or_settings).toString(), settings)
          url = url_or_settings['url']
          delete url_or_settings['url']
          $.ajax(Spree.url(url).toString(), url_or_settings)
        states_search: @pathFor('api/states')
        apply_coupon_code: (order_id) ->
    • Public Snippets
    • Channels Snippets