This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import timedelta, datetime | |
from django.utils import timezone | |
from django.test import TestCase | |
from django import template | |
register = template.Library() | |
@register.filter() | |
def timeago(dt: datetime, now_dt: datetime=None) -> str: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"golang.org/x/tour/tree" | |
) | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. | |
func Walk(t *tree.Tree, ch chan int) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if param.status == 1 %} | |
<!-- 特定の条件の場合activeというクラス名をつける --> | |
<li class="active"> | |
{% else %} | |
<li> | |
{% endif %} | |
<a href="#">Active</a> | |
</li> | |
…… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$obj = simplexml_load_string($xml); | |
$json = json_encode($obj); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<provider | |
android:name="com.activeandroid.content.ContentProvider" | |
android:authorities="APKのパッケージ名" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import markdown | |
md = markdown.Markdown() | |
sample_makedown = ''' | |
An h1 header | |
============ | |
Paragraphs are separated by a blank line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.appspot.pistatium.tomorrow.service; | |
import java.util.Calendar; | |
import java.util.TimeZone; | |
import android.app.AlarmManager; | |
import android.app.PendingIntent; | |
import android.content.Context; | |
import android.content.Intent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python2.7 | |
import md5 | |
def hexTo64(hex): | |
result = [] | |
for i in range(8): | |
# 16 * 16 / 4 = 64 | |
tmp = int(hex[i * 2: i * 2 + 2],16) / 4 | |
if tmp < 26: | |
# A-Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
データを手っ取り早くテーブルにして表示するための関数 | |
何を表示するかを定義したheaderと、 | |
配列形式で複数行のデータが入ったdataを渡すと | |
テーブルのHTMLを返す | |
*/ | |
var tableBuilder = function(header, data) { | |
var html = '<table class="table"><thead><tr>'; | |
for (var key in header) { | |
html += '<th id="label_' + key + '">' + header[key] + '</th>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$arr = array( | |
"first" => 1, | |
"second" => 2, | |
); | |
echo "\nBefore \n"; | |
print_r($arr); |