Search This Blog

2017/02/25

Share blogger's blogs/pages to Tumblr/Line/Linkedin

Blogger already has some share buttons like "google+", "twitter"... and maybe you want to share to Tumblr or Line.

To add Tumblr or Line share button, you need to edit blogger's template.

In template | edit html
Search "<b:includable id='shareButtons' var='post'>"

Then add the code inside this b:includable
Tumblr
<a class="tumblr-share-button" href="https://www.tumblr.com/share"></a>
Add the script before </body>
<script id="tumblr-js" async src="https://assets.tumblr.com/share-button.js"></script>
show as:

Line
<a expr:href='&quot;http://line.naver.jp/R/msg/text/?&quot; + data:post.title + &quot;%0D%0A&quot; + data:post.url + &quot;&quot;'> <img alt='LINEで送る' height='20px' src='https://media.line.me/img/button/ja/20x20.png' width='20px'/></a>
show as: LINEで送る

Linkedin
<script data-counter='right' type='IN/Share'>var data-url = &#39;<data:post.sharePostUrl/>&#39;;</script>
Add the script before </body>
<script src='//platform.linkedin.com/in.js' type='text/javascript'> lang: en_US</script>

2017/02/24

MySQL event scheduler

Attention: event_scheduler is supported after 5.1

Check if event_scheduler is on, execute:
SHOW VARIABLES LIKE 'event_scheduler';
To set event_scheduler on:
SET GLOBAL event_scheduler = ON;
or SET @@global.event_scheduler = ON;
or SET GLOBAL event_scheduler = 1;
or SET @@global.event_scheduler = 1;
To turn off is
SET GLOBAL event_scheduler = OFF;
or SET @@global.event_scheduler = OFF;
or SET GLOBAL event_scheduler = 0;
or SET @@global.event_scheduler = 0;

To create event:

CREATE EVENT [IF NOT EXISTS] event_name
  ON SCHEDULE schedule
  [ON COMPLETION [NOT] PRESERVE]
  [ENABLE | DISABLE]
  [COMMENT 'comment']
  DO sql_statement;
param
schedule:
  AT TIMESTAMP [+ INTERVAL INTERVAL]
                              | EVERY INTERVAL [STARTS TIMESTAMP] [ENDS TIMESTAMP]
INTERVAL:
  quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |
                   WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |
                   DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}

2017/02/21

Customize your blogger: ads and page type

Customize your ads' position.
<!-- show Ad if you set ads to show in your blogger -->
<b:if cond='data:post.includeAd'>
<div class='inline-ad'>
<data:adCode/>
</div>
</b:if>

<!-- show only when it is static page or item(post page) -->
<b:if cond='data:blog.pageType in {&quot;static_page&quot;,&quot;item&quot;}'>
<!-- your code -->
</b:if>

<!-- show only when it is index page -->
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<!-- your code -->
</b:if>

<!-- show only when device is mobile -->
<b:if cond='data:blog.isMobile'>
<!-- your code -->
</b:if>

2017/02/15

Drag & drop file code sample

Make a div for dropping.
$("#id").on("drop dragover", function(e) {
 var fm = document.getElementById('form');
 var fd = new FormData(fm);
 e.preventDefault();
 if (e.type === "drop") {
  var files = e.originalEvent.dataTransfer.files;
  console.log(files);
  if (files.length > 0) {
   fd.append("file", files[0]);
   // do something
  }
 }
 return false;
});
html part:
<form action="upload.php" enctype="multipart/form-data" id="form" method="post">
  <input name="mode" type="hidden" value="upload" />
  <input id="formFile" name="file" type="file" />
</form>

2017/02/09

Create array in array

1:
var myArray = [[]];
2:
var myArray1 = new Array();
myArray.push(new Array());
myArray[i]= myArray1;
3:
var myArray1 = new Array({name: "name", value: "value"});
myArray.push({name: "name", value: "value"});

Set back function with toolbar

Set:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

Action:
onBackPressed();

2017/02/07

Insert two rows into db with one sql

MySQl
insert into table(columns...)values(value1...),(value2...),(value3...)
add more rows by ,(value...)
Oracle
insert all
into table(columns...)values(value1...)
into table(columns...)values(value2...)
select 1 from dual