This file contains hidden or 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
select tt.created, tt.number, ht.topic, tc.subject, ts.name as 'STATUS', u.name, uc.phone, ue.address from ost_thread t | |
inner join ost_ticket tt on t.id = tt.ticket_id | |
inner join ost_ticket__cdata tc on tc.ticket_id = tt.ticket_id | |
inner join ost_ticket_status ts on ts.id = tt.status_id | |
inner join ost_user u on tt.user_id = u.id | |
inner join ost_user__cdata uc on uc.user_id = u.id | |
inner join ost_user_email ue on ue.user_id = u.id | |
inner join ost_help_topic ht on ht.topic_id = tt.topic_id | |
where t.object_type = 'T' | |
-- and tt.number = 506581 |
This file contains hidden or 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
// di suatu fungsi pada sebuah model booking | |
protected function generateKodeBooking() | |
{ | |
$penyewa = $this->penyewa_id; | |
$disewa = $this->disewa_id; | |
// dapatkan random char sebanyak 5 buah | |
// https://stackoverflow.com/questions/5438760/generate-random-5-characters-string | |
$rndchar = substr(str_shuffle(str_repeat("123456789ABCDEFGHJKLMNPQRSTUVWXYZ", 5)), 0, 5); | |
return sprintf("%s%d%d", $rndchar, $penyewa, $disewa); | |
} |
This file contains hidden or 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
// https://tour.golang.org/concurrency/8 | |
package main | |
import "golang.org/x/tour/tree" | |
import "fmt" | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. | |
func Walk(t *tree.Tree, ch chan int) { | |
// we need to close channel, so it need to call separately | |
recursiveWalk(t, ch) |
This file contains hidden or 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
func longestPalindrome(s string) string { | |
start, end := 0, 0 | |
part := 1 | |
maxPal, maxStart, maxEnd := 0, 0, 0 | |
lenS := len(s) | |
nowBreak := false | |
for i:=0;i<lenS;i++ { | |
// looping for first try, the even pal | |
for { | |
if i - part < 0 || i + part >= lenS { |
This file contains hidden or 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" | |
) | |
func main() { | |
test := "able was i ere i saw elba" | |
testBalik := reverseString(test) | |
if test == reverseString(test) { |
This file contains hidden or 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
$('ul.nav a[href="' + window.location + '"]').parent().addClass('active'); |
This file contains hidden or 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
/** | |
* assume Post has belongsToMany relationship with Category, and Category has belongsToMany relationship with Post named posts | |
* | |
* we need to get all posts that belongs to a category ... | |
*/ | |
$posts = Category::find($idCategory)->posts()->get(); | |
// test | |
foreach($posts as $p) | |
{ |
This file contains hidden or 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
namespace app\lib\ModelSlug; | |
/** | |
* Imagine we have Category and Post, and we want to search for Post that are in Category, using a slug | |
* of Category. | |
* | |
* In controller ... | |
* | |
* $posts = Category::findSlugOrFail($theSlugFromRoute, $the_slug_field)->posts()->get(); | |
* | |
* If failed, it will throw the same exception as findOrFail did. |