我觉得这对我来说是一个愚蠢的错误,但我无法弄清楚如何使用google-api-php-client进行简单的搜索.我的目标是针对我的网站针对谷歌搜索引擎运行简单的关键字查询.
我已经创建了我的api密钥,一个谷歌搜索引擎并下载了api客户端的版本,但是php客户端的google网站似乎没有任何关于如何使用客户端的文档和我唯一的相关示例到目前为止发现了专门搜索谷歌的图书服务.问题是该示例意味着不同的搜索服务具有不同的搜索结果类型,我找不到任何关于如何从a检索结果的文档Google_Service.
我想我可以设置这样的简单搜索,但我不知道如何实际检索结果.
include_once __DIR__ . '/vendor/autoload.php';
...
public function __construct($searchTerm) {
$client = new Google_Client();
$client->setApplicationName("My_First_Search");
$client->setDeveloperKey(self::GCSE_API_KEY);
$service = new Google_Service($client);
$optParams = array('filter' => $searchTerm);
$results = $service->???
Run Code Online (Sandbox Code Playgroud)
文档必须在那里,但它不在任何明显的地方....
(更新1/21/17:实际上,这些文档对我没什么帮助,但我会把它们留给我们)
我使用phpdoc为google生成api文档apiclient.我做了一个回购,把phpdoc和libary放在github上.该phpdocs是可浏览这里.
所以希望这会对某人有所帮助.不幸的是,即使使用文档,我也无法解开正确的用法.我还没有为google apiclient-services软件包生成文档,因为它们很大,但我可以在必要时这样做(取决于github页面上的磁盘限制).
我试图找出如何在许多未提交的更改中存储两个特定文件.
这个非常有前途的答案,Stash只有一个文件中的多个文件已经改变了Git?,没有显示用法,我遇到了麻烦.
以下不起作用,手册页不是很有帮助(它似乎谈论终端输出,而不是实际存储).我想隐藏application.conf,plugins.sbt然后提交其他所有内容.
app (master)$ git status
On branch master
Your branch is ahead of 'origin/master' by 29 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: views/mobile/blog.scala.html
modified: views/mobile/slideshow.scala.html
modified: ../public/css/mobile/styles.css
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: ../conf/application.conf
Changes not staged for commit:
(use "git add <file>..." to update …Run Code Online (Sandbox Code Playgroud) 符合指南 typeorm:https : //github.com/typeorm/typeorm/blob/master/docs/select-query-builder.md#inner-and-left-joins
这部分我不是很明白:
(type => Photo, photo => photo.user)
Run Code Online (Sandbox Code Playgroud)
什么意思类型?照片 => 照片是什么意思。? . 链接上的解释不好。
部分代码:
Import {Entity, PrimaryGeneratedColumn, Column, OneToMany} from "typeorm";
import {Photo} from "./Photo";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToMany(type => Photo, photo => photo.user)
photos: Photo[];
}
Run Code Online (Sandbox Code Playgroud)
并在代码上:
const user = await createQueryBuilder("user")
.leftJoinAndSelect("user.photos", "photo")
.where("user.name = :name", { name: "Timber" })
.getOne();
Run Code Online (Sandbox Code Playgroud)
“user.photos”从何而来?
我只是第一次尝试使用Atom,我觉得Atom为我点击的每个文件打开一个新窗口很麻烦 - 我宁愿它默认在同一个窗口打开每个文件.
我希望有一些与"open_files_in_new_window" : false,Sublime相似的东西.不幸的是,我看到的所有谷歌搜索结果只是感叹这个切换并不是很明显.
问题是,投影似乎是在元素周围绘制的.虽然我希望通过背景图像的透明部分看到阴影颜色,但我会看到背景颜色(请参阅此jsfiddle).
我的实际目标有点复杂,但如果我能满足前三个要点那么我就可以完成这项任务.具体来说,我想要做的是使用两个嵌套元素与按钮图像的右侧和左侧部分(圆角)的背景图像,以便我可以使用相同的CSS在任何长度的文本周围包裹"按钮".由于背景在css'滑动门'样式中重叠,因此png alpha阴影显示图像重叠的2x暗部分.Soo ..我以为我会使用css阴影,但正如你在jsFiddle中看到的那样,也存在问题.
有任何想法吗?
CandidateEntity
@Entity({ name: 'users' })
export class CandidateEntity {
@PrimaryGeneratedColumn()
public id: number;
@OneToOne(() => CandidateEmployeeInfoEntity, employeeInfo => employeeInfo.candidate)
public employeeInfo: CandidateEmployeeInfoEntity;
}
Run Code Online (Sandbox Code Playgroud)
EmployeeInfoEntity
@Entity({ name: 'candidates_employee_infos' })
export class CandidateEmployeeInfoEntity {
@PrimaryGeneratedColumn()
public id: number;
@Column({ type: 'bool', nullable: false })
public relocation: boolean;
@Column({ type: 'text', nullable: true })
public softSkills: string;
@OneToOne(() => CandidateEntity, candidate => candidate.employeeInfo)
public candidate: CandidateEntity;
@Column({ type: 'integer' })
public candidateId: number;
}
Run Code Online (Sandbox Code Playgroud)
我创建查询以从数据库中的 104 行中选择前 25 行
const {
perPage = …Run Code Online (Sandbox Code Playgroud) 我在代码中遇到了意外(对我而言)的行为,所以我试图在REPL中找出问题所在.但是,这些构造函数似乎都具有相同的结果(空哈希):
irb> a = {}
# => {}
irb> b = Hash.new(0)
# => {}
Run Code Online (Sandbox Code Playgroud)
当我{}进入reduce函数时,我得到一个NoMethodError.这两个构造函数有什么区别?
irb> arr = "count the occurance of each of the words".scan(/\w+/)
# => ["count", "the", "occurance", "of", "each", "of", "the", "words"]
irb> x = arr.reduce(Hash.new(0)) { |hsh, word| hsh[word] += 1; hsh }
# => {"count"=>1, "the"=>2, "occurance"=>1, "of"=>2, "each"=>1, "words"=>1}
irb> x = arr.reduce({}) { |hsh, word| hsh[word] += 1; hsh }
# NoMethodError: undefined method `+' for nil:NilClass
Run Code Online (Sandbox Code Playgroud) 我正在编写虚假的电子邮件地址,我只是想确保它们是有效的电子邮件格式,所以我试图删除下面集合中没有的任何字符:
$jusr['email'] = preg_replace('/[^a-zA-Z0-9.-_@]/g', '', $jusr['email']);
Run Code Online (Sandbox Code Playgroud)
我在我的Windows机器上没遇到任何问题,但是在linux dev服务器上,每次运行此代码时都会出现此错误:
Warning: preg_replace() [function.preg-replace]: Unknown modifier 'g' in /var/www/vhosts/....
Run Code Online (Sandbox Code Playgroud)
我认为这是正则表达式字符串,但我不能把它固定下来.帮助不大?谢谢.
澄清:我不是想要容纳所有有效的电子邮件地址(我的目的不必要),我只需要弄清楚我的preg_replace正则表达式有什么问题.
我试图找出正确的Ember.js模型这个项目的方法,例如.需要什么型号,路线和控制器. 我已经开始使用jsBin了.
我的要求可以安全地降低到:
物品及其选择
仪表板
导航
数据
那么在Ember中如何构建呢?
我曾尝试过一次这样做,但这是我的第一次尝试,最后我得到了一个非常丑陋的设置.我想看看Ember经验的人会如何接近这个:
jsBin Mockup(链接)
我已经创建了一系列车把模板,但没有尝试应该存在哪些型号以及需要哪些控制器.

JSON
{
"Items" : [
{
"Item" : {
"nid" : "3",
"title" : "Hydro",
"image" : "http://bpf.vm/sites/default/files/bpf_things/hydro.jpg",
"properties" : "Baseload, Intermittent",
"values" : {
"Cost" : {
"price" : "6",
"quantity" : null
},
"Percent of Portfolio" : {
"price" : null,
"quantity" : "56"
}
},
"options" : {
"1" …Run Code Online (Sandbox Code Playgroud) php ×2
typeorm ×2
api ×1
architecture ×1
atom-editor ×1
constructor ×1
css ×1
css3 ×1
ember.js ×1
git ×1
git-stash ×1
hash ×1
javascript ×1
node.js ×1
preg-replace ×1
prettier ×1
regex ×1
ruby ×1
transparency ×1
warnings ×1