working on it ...

Filters

Explore Public Snippets

Sort by

Found 1.6M snippets

    public by Watson modified Friday at 9:25:02 AM  24  1  2  1

    simple Generator duplicate classes CSS

    		<?php
    		if(isset($_POST['submit'])){
    			$count = $_POST['count'];
    			$shag = $_POST['shag'];
    			$prefix = $_POST['prefix'];
    			$postfix = $_POST['postfix'];
    			$attribut = $_POST['attribut'];
    			$znachenie = $_POST['znachenie'];
    		}
    		function rasschet($count, $shag, $prefix, $postfix, $attribut, $znachenie){
    			$html = '';
    			for($i = 0; $i<=$count; $i++){
    				if ($shag != ''){
    					if($i%$shag == 0){
    						$html .= ".".$prefix.$i.$postfix." { ".$attribut.": ".$i.$znachenie.";}<br/>";
    					}
    				}
    			}
    			echo $html;
    		}
    
    		?>
    		<!DOCTYPE html>
    		<html lang="ru">
    		<head>
    			<meta charset="UTF-8">
    			<title>simple Generator duplicate classes CSS</title>
    		</head>
    		<body>
    			<div class="container">
    				<div class="row">
    					<div class="page-header">
    						<h2>Generator duplicate CSS .class {attr: value;}</h2>
    					</div>
    				</div>
    				<div class="row">
    				<div class="panel-group"><div id="examp" class="panel panel-success"><div class="panel-heading"><a data-toggle="collapse" href="#collapse0" class="btn btn-primary"> <i class="indicator glyphicon glyphicon-collapse-down"></i> Example</a></div><div id="collapse0" class="panel-collapse collapse "><div class="panel-body">
    					<div class="col-sm-6">
    											<div class="panel panel-primary">
    							<div class="panel-heading"><h4>example input:</h4></div>
    							<div class="panel-body">
    							max volume : 25<br/>
    							step: 5<br/>
    							prefix : max_w<br/>
    							postfix : p<br/>
    							attribute class : max-width<br/>
    							units : %
    					</div>
    				</div>
    					</div>
    					<div class="col-sm-6">
    						<div class="panel panel-primary">
    							<div class="panel-heading"><h4>example out:</h4></div>
    							<div class="panel-body">
    							<code>.max_w0p { max-width: 0%;}<br/>
    							.max_w5p { max-width: 5%;}<br/>
    							.max_w10p { max-width: 10%;}<br/>
    							.max_w15p { max-width: 15%;}<br/>
    							.max_w20p { max-width: 20%;}<br/>
    							.max_w25p { max-width: 25%;}</code>
    						</div>
    						</div>
    					</div>
    					</div></div></div></div>
    				</div>
    				<div class="row">
    					<div class="col-md-6">
    						<div class="thumbnail">
    							<form action="service_css.php" method="post">
    								<div class="form-group"><input type="text" name="count" value="" placeholder="max volume attribute of class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="shag" value="" placeholder="step volume" class="form-control"></div>
    								<div class="form-group"><input type="text" name="prefix" value="" placeholder="prefix of name css class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="postfix" value="" placeholder="postfix of name css class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="attribut" value="" placeholder="attribute class" class="form-control"></div>
    								<div class="form-group"><input type="text" name="znachenie" value="" placeholder="units: em, rem, px, pt or %" class="form-control"></div>
    								<div class="form-group"><input type="submit" name="submit" value="Submit" class="btn btn-success btn-block"></div>
    							</form>
    						</div>
    					</div>
    					<div class="col-md-6">
    						<div class="thumbnail">
    							<?php 
    //echo $html;
    							rasschet($count, $shag, $prefix, $postfix, $attribut, $znachenie);
    							?>
    						</div>
    					</div>
    				</div>
    			</div>
    
    
    			<!-- Latest compiled and minified CSS & JS -->
    			<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    			<script src="//code.jquery.com/jquery.js"></script>
    			<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>	
    			<script>
    function toggleChevron(e) {
        $(e.target)
            .prev('.panel-heading')
            .find("i.indicator")
            .toggleClass('glyphicon-collapse-down glyphicon-collapse-up');
    }
    $('#examp').on('hidden.bs.collapse', toggleChevron);
    $('#examp').on('shown.bs.collapse', toggleChevron);
    			</script>
    		</body>
    		</html>            

    public by fadzly modified Thursday at 3:58:40 AM  17  0  2  0

    Saving date in Magento

    Saving date in Magento
    Mage::getModel('plansetter/dailyscheduledraft')
                                        ->setId()
                                        ->setScheduleDate(Mage::getModel('core/date')->gmtDate(null, date("d-m-Y")))

    public by sebastian.piskorski modified Tuesday at 3:14:14 PM  24  0  3  0

    [MySQL] Calculate Database size

    [MySQL] Calculate Database size using simple single query.
    SELECT table_schema "Data Base Name",
        sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
        sum( data_free )/ 1024 / 1024 "Free Space in MB"
    FROM information_schema.TABLES
    GROUP BY table_schema ;

    public by mmngreco modified Jan 15, 2017  17  0  1  0

    hello_world

    #!/bin/python3
    # Test
    print("Hello, World!")

    public by p.kontalis modified Jan 13, 2017  34  0  3  0

    Replace Assembly.LoadWithPartialName with Assembly.Load

    The Assembly.LoadWithPartialName has been deprecated. From now on you have to use Assembly.Load
    '###Till .NET Framework 2.0 you can Load an assembly by its name
    Dim FormsAssembly As Reflection.Assembly = Reflection.Assembly.LoadWithPartialName("System.Windows.Forms")
    
    '###After .Net Framework 2.0 you have to use Assembly.Load
    '###Therefore you have to give all the assembly information but the public token is not the same per pc
    Dim FormsAssembly As Reflection.Assembly = Reflection.Assembly.Load("System.Windows.Forms, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 7a84f7ac56134e3a")
    
    '###In order to bypass this wall either you retrieve it from the registry or you use the GetType(Form) for the retrieval.
    Dim AssemblyLoadString As String = GetType(Form).AssemblyQualifiedName.ToString.Substring(GetType(Form).AssemblyQualifiedName.ToString.IndexOf(",") + 2)
    Dim FormsAssembly As Reflection.Assembly = Reflection.Assembly.Load(AssemblyLoadString)                        

    public by simos modified Jan 11, 2017  33  1  3  0

    html 5 template

     
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    
    <script src="https://use.fontawesome.com/f7fe6f4f19.js"></script>
    
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    
    <body></body>
    
    
    </html>                        

    public by bobby modified Jan 10, 2017  35  0  2  0

    Returns Descriptions for all active Magento products

    Returns Descriptions for all active Magento products: Magento-active-product-descriptions.sql
    SELECT 
        e.entity_id,
        e.sku,
        eav.value AS 'description',
        IF(at_status.value_id > 0,
            at_status.value,
            at_status_default.value) AS `status`
    FROM
        catalog_product_entity e
            JOIN
        catalog_product_entity_text eav ON e.entity_id = eav.entity_id
            JOIN
        eav_attribute ea ON eav.attribute_id = ea.attribute_id
            INNER JOIN
        `catalog_product_entity_int` AS `at_status_default` ON (`at_status_default`.`entity_id` = `e`.`entity_id`)
            AND (`at_status_default`.`attribute_id` = '89')
            AND `at_status_default`.`store_id` = 0
            LEFT JOIN
        `catalog_product_entity_int` AS `at_status` ON (`at_status`.`entity_id` = `e`.`entity_id`)
            AND (`at_status`.`attribute_id` = '89')
            AND (`at_status`.`store_id` = 1)
    WHERE
        ea.attribute_code = 'description'
            AND IF(at_status.value_id > 0,
            at_status.value,
            at_status_default.value) = 1
    LIMIT 9999
    
                

    public by cghersi modified Jan 10, 2017  52  1  4  1

    How to write bytes into file in Java

    Efficient way to write strings or bytes onto a file.
      import java.nio.file.Files;
      import java.nio.file.Paths;
    
      public static void writeFile(String path, String content) throws Exception {
    		if (isNullOrEmpty(path) || isNullOrEmpty(content)) {
    			return;
    		}
    		Files.write(Paths.get(path), content.getBytes());
    	}                     

    public by cghersi modified Jan 10, 2017  40  1  3  1

    Read file in Java

    Efficient way to read file in Java using Files class
      import java.nio.file.Files; 
      import java.nio.file.Paths;
    
      public static String readFile(String path) throws Exception {
    		if (isNullOrEmpty(path)) {
    			return "";
    		}
    		return new String(Files.readAllBytes(Paths.get(path)));
    	}      

    public by cghersi modified Jan 10, 2017  541  3  7  0

    How to read a file into a string in Java

    This simple snippet reads a file and put the content into a returned string
    private static String readFileAsString(String filePath) throws java.io.IOException{
    
    	StringBuffer fileData = new StringBuffer(1000);
    	BufferedReader reader = new BufferedReader(new FileReader(filePath));
    	char[] buf = new char[1024];
    	int numRead=0;
    	while((numRead=reader.read(buf)) != -1){
    		String readData = String.valueOf(buf, 0, numRead);
    		fileData.append(readData);
    		buf = new char[1024];
    	}
    
    	reader.close();
    	return fileData.toString();
    }            
    • Public Snippets
    • Channels Snippets